diff --git a/.cish/docker.sh b/.cish/docker.sh new file mode 100644 index 0000000..a666a2c --- /dev/null +++ b/.cish/docker.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -e + +cish add docker cish:pathfilter + +pathfilter "$CTX" +cd "$CTX" + +docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" +docker login -u "$GHCR_USERNAME" -p "$GHCR_PASSWORD" ghcr.io + +SHOULD_PUSH=$([[ "$EVENT" == "tag" || "$REF" == "master" ]] && echo true || echo false) + +IMAGE="$REPOSITORY_OWNER/kyoo_$CTX" +# TODO: +# - name: Docker meta +# id: meta +# uses: docker/metadata-action@v5 +# with: +# images: | +# docker.io/${{matrix.image}},enable=${{ env.DOCKERHUB_ENABLED }} +# ghcr.io/${{matrix.image}} +# tags: | +# type=edge +# type=ref,event=branch +# type=ref,event=pr +# type=semver,pattern={{version}} +# type=semver,pattern={{major}}.{{minor}} + +# TODO: auto-cache this +docker build . \ + --push "$SHOULD_PUSH" \ + --tag "docker.io/$IMAGE:$TAG" \ + --tag "ghcr.io/$IMAGE:$TAG" + +if $SHOULD_PUSH; then + pkg add github:ms-jpq/sync-dockerhub-readme + dockerhub-sync -u "$DOCKER_USERNAME" -p "$DOCKER_PASSOWRD" "$IMAGE" ./README.md +fi diff --git a/.cish/ex.sh b/.cish/ex.sh new file mode 100644 index 0000000..268a5bf --- /dev/null +++ b/.cish/ex.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +cish add "go@$VERSION" diff --git a/.cish/push/coding-style/api.sh b/.cish/push/coding-style/api.sh new file mode 100644 index 0000000..8150f53 --- /dev/null +++ b/.cish/push/coding-style/api.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +pkg add biome +biome ci ./api diff --git a/.cish/push/coding-style/auth.sh b/.cish/push/coding-style/auth.sh new file mode 100644 index 0000000..4dc9b58 --- /dev/null +++ b/.cish/push/coding-style/auth.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +pkg add go +if [ "$(gofmt -s -l ./auth | wc -l)" -gt 0 ]; then + exit 1 +fi diff --git a/.cish/push/coding-style/front.sh b/.cish/push/coding-style/front.sh new file mode 100644 index 0000000..932d8d1 --- /dev/null +++ b/.cish/push/coding-style/front.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +pkg add biome +biome ci ./front diff --git a/.cish/push/coding-style/scanner.sh b/.cish/push/coding-style/scanner.sh new file mode 100644 index 0000000..6fc87dc --- /dev/null +++ b/.cish/push/coding-style/scanner.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +pkg add ruff +ruff format --check ./scanner diff --git a/.cish/push/docker.sh b/.cish/push/docker.sh new file mode 100644 index 0000000..0b6c1fb --- /dev/null +++ b/.cish/push/docker.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +for ctx in back api front scanner autosync transcoder auth; do + cish run --name "$ctx" ../docker.sh --ctx "$ctx" +done diff --git a/.cish/push/helm-releaes.sh b/.cish/push/helm-releaes.sh new file mode 100644 index 0000000..16a062f --- /dev/null +++ b/.cish/push/helm-releaes.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +cish add helm docker + +docker login -u "$GHCR_USERNAME" -p "$GHCR_PASSWORD" ghcr.io +helm dependency update ./chart + +TAG=${REF#refs/tags/v/} +REPO_NAME="$(echo "oci://ghcr.io/${REPOSITORY_OWNER}/helm-charts" | tr '[:upper:]' '[:lower:]')" + +helm package ./chart --version "$TAG" --app-version "$TAG" +helm push kyoo-*.tgz "${REPO_NAME}" diff --git a/.cish/push/helm-test.sh b/.cish/push/helm-test.sh new file mode 100644 index 0000000..5d568d2 --- /dev/null +++ b/.cish/push/helm-test.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +cish add helm kind +helm lint ./chart + +helm dependency update ./chart + +kind create cluster + +helm install test-release ./chart --dry-run --debug +helm install test-release ./chart + +kubectl get all + +kind delete cluster diff --git a/.cish/push/hurl.sh b/.cish/push/hurl.sh new file mode 100644 index 0000000..6918d45 --- /dev/null +++ b/.cish/push/hurl.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -e + +cish add pathfilter +cd ./auth +pathfilter ./auth + +cish start postgres:15 \ + --port 5432:5432 \ + -e POSTGRES_USER=kyoo \ + -e POSTGRES_PASSWORD=password \ + --health-cmd pg_isready \ + --health-interval 10s \ + --health-timeout 5s \ + --health-retries 5 \ + +cish add hurk go + +go mod download +go build -o ./keibi + +export PGHOST=localhost +export FIRST_USER_CLAIMS='{"permissions": ["users.read"]}' +export KEIBI_APIKEY_HURL=1234apikey +export KEIBI_APIKEY_HURL_CLAIMS='{"permissions": ["apikeys.write", "apikeys.read"]}' +./keibi > logs & +trap 'cat logs' EXIT +wget --retry-connrefused --retry-on-http-error=502 http://localhost:4568/auth/health + +hurl --error-format long --variable host=http://localhost:4568/auth tests/* diff --git a/.cish/push/matrix.sh b/.cish/push/matrix.sh new file mode 100644 index 0000000..e6e28d0 --- /dev/null +++ b/.cish/push/matrix.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +cish start postgres + +for job in v1.22.0 v1.0.0 titi; do + cish run ../ex.sh --version=$job + + cish run --name "go-$job" --ref=master - --version=$job <<-eof + cish add go@$VERSION + eof +done diff --git a/.cish/push/native-build.sh b/.cish/push/native-build.sh new file mode 100644 index 0000000..10001dc --- /dev/null +++ b/.cish/push/native-build.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +cish add cish:pathfilter expo yarn +pathfilter front + +yarn install --immutable + +cish secret EXPO_TOKEN +yarn build:mobile:apk | tee log.txt + +ASSET_URL=$(jq '.[0].artifacts.buildUrl' -r < log.txt) +echo "The android url is $ASSET_URL" + +wget -O "$RELEASE/kyoo.apk" "$ASSET_URL" diff --git a/.cish/push/native-update.sh b/.cish/push/native-update.sh new file mode 100644 index 0000000..2b47281 --- /dev/null +++ b/.cish/push/native-update.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +cish add cish:pathfilter expo yarn +pathfilter front + +yarn install --immutable + +cish secret EXPO_TOKEN +yarn update diff --git a/.cish/push/release.sh b/.cish/push/release.sh new file mode 100644 index 0000000..63299c5 --- /dev/null +++ b/.cish/push/release.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +VERSION=${REF:1} # Remove v prefix +VERSION=${REF%.*} # Remove minor version +sed "s/edge/$VERSION/" -i docker-compose.yml + +cp docker-compose.yaml .env.example "$RELASE/" diff --git a/.cish/push/test.sh b/.cish/push/test.sh new file mode 100644 index 0000000..d56eb9a --- /dev/null +++ b/.cish/push/test.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +cish start postgres:15 \ + --port 5432:5432 \ + -e POSTGRES_USER=kyoo \ + -e POSTGRES_PASSWORD=password \ + --health-cmd pg_isready \ + --health-interval 10s \ + --health-timeout 5s \ + --health-retries 5 \ + +pkg add bun pathfilter +cd ./api + +if pathfilter ./api; then + echo "No changes on ./api. aborting" + exit 0 +fi + +bun install --frozen-lockfile +bun test +PGHOST=localhost bun test