Skip to content

Commit

Permalink
ci: tweak Act setup
Browse files Browse the repository at this point in the history
  • Loading branch information
getlarge committed Aug 16, 2024
1 parent 27dda54 commit 9296338
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

# --require-explicit-completion because Nx agents might not receive tasks for more than 30 seconds when preparing the e2e test environment
# @see https://nx.dev/ci/troubleshooting/ci-execution-failed#the-nx-cloud-heartbeat-process-failed-to-report-its-status-in-time
- run: npx nx-cloud start-ci-run --distribute-on="3 linux-small-js" --stop-agents-after="e2e-ci" --require-explicit-completion --with-env-vars="DOTENV_PRIVATE_KEY_CI,POSTGRES_DB,POSTGRES_URL"
- run: npx nx-cloud start-ci-run --distribute-on="3 linux-small-js" --require-explicit-completion --with-env-vars="DOTENV_PRIVATE_KEY_CI,POSTGRES_DB,POSTGRES_URL"
if: ${{ env.NX_CLOUD_DISTRIBUTED_EXECUTION == 'true' }}

- uses: actions/setup-node@v4
Expand Down Expand Up @@ -68,21 +68,27 @@ jobs:
- run: npx nx run cat-fostering-api:container --skip-nx-cache --no-agents --platforms=linux/amd64 --load=true --push=false --tags='ghcr.io/getlarge/cat-fostering/cat-fostering-api:${{ env.DOCKER_API_TAG }}'

# can't use --wait --wait-timeout N options since Keto and Kratos migrate containers will exit before the Keto and Kratos services are ready
- run: npx @dotenvx/dotenvx run -- docker compose --profile ci -p cat-fostering up -d
- run: npx dotenvx run -- docker compose --profile ci -p cat-fostering up -d
env:
DOCKER_API_TAG: ${{ env.DOCKER_API_TAG }}

- run: sleep 10

# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
- run: npx nx-cloud record -- docker ps
- run: npx nx-cloud record -- docker compose -p cat-fostering logs keto -n 500
- run: npx nx-cloud record -- docker compose -p cat-fostering logs kratos -n 500
- run: |
npx nx-cloud record -- docker ps
npx nx-cloud record -- docker compose -p cat-fostering logs keto -n 500
npx nx-cloud record -- docker compose -p cat-fostering logs kratos -n 500
- name: Run e2e tests
run: npx nx affected -t e2e --no-agents
# if: ${{ env.NX_CLOUD_DISTRIBUTED_EXECUTION == 'false' }}

- if: failure()
run: |
npx nx-cloud record -- docker compose -p cat-fostering logs api -n 200
npx nx-cloud record -- docker compose -p cat-fostering logs kratos -n 200
# to enable DTE for e2e tests splitting, use the following command instead and set stop-agents-after="e2e-ci"
# - name: Run distributed e2e tests
# run: |
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci: ## Run CI workflow defined in GitHub Actions CI workflow.

# export GITHUB_TOKEN=$(gh auth token)
# export DOTENV_PRIVATE_KEY_CI=$(cat .env.keys | grep DOTENV_PRIVATE_KEY_CI | cut -d '=' -f2 | tr -d '"')
@act push --container-daemon-socket="unix:///var/run/docker.sock" --bind --env-file='' --var NX_CLOUD_DISTRIBUTED_EXECUTION=true -s GITHUB_TOKEN="${GITHUB_TOKEN}" -s DOTENV_PRIVATE_KEY_CI=${DOTENV_PRIVATE_KEY_CI} --pull=true -e github_event.tmp
@act push --container-daemon-socket="unix:///var/run/docker.sock" --bind --env-file='' --var NX_CLOUD_DISTRIBUTED_EXECUTION=${NX_CLOUD_DISTRIBUTED_EXECUTION:-false} -s GITHUB_TOKEN="${GITHUB_TOKEN}" -s DOTENV_PRIVATE_KEY_CI=${DOTENV_PRIVATE_KEY_CI} --pull=true -e github_event.tmp
@rm -f github_event.tmp


Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"docker:caddy:build": "docker buildx build infra/caddy -f infra/caddy/Dockerfile -t ghcr.io/getlarge/cat-fostering/caddy --load",
"docker:caddy:push": "docker buildx build infra/caddy -f infra/caddy/Dockerfile --platform linux/amd64,linux/arm64 -t ghcr.io/getlarge/cat-fostering/caddy --push",
"nsci": "nsci",
"ci:run": "make ci",
"ci:clean": "make ci-clean",
"postinstall": "patch-package",
"prepare": "husky"
},
Expand Down

0 comments on commit 9296338

Please sign in to comment.