From fe50abde33028db1016c9af77137616633421711 Mon Sep 17 00:00:00 2001 From: Jonathan Sharpe Date: Fri, 11 Oct 2024 13:19:34 +0100 Subject: [PATCH] Simplify build in CYF version --- bin/cyf.sh | 3 +- bin/files/push.yml | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 bin/files/push.yml diff --git a/bin/cyf.sh b/bin/cyf.sh index d75eed2d..63e9fc4f 100755 --- a/bin/cyf.sh +++ b/bin/cyf.sh @@ -28,7 +28,8 @@ mv "$HERE/files/README.md" "$ROOT" mv "$HERE/files/render.yaml" "$ROOT" mv "$HERE/files/user-story.md" "$ROOT/.github/ISSUE_TEMPLATE/" -rm "$ROOT/.github/workflows/keepalive.yml" +rm "$ROOT/.github/workflows"/*.yml +mv "$HERE/files/push.yml" "$ROOT.github/workflows/" rm "$ROOT/.github/CODE_OF_CONDUCT.md" rm "$ROOT/.github/CONTRIBUTING.md" rm "$HERE/cyf.sh" diff --git a/bin/files/push.yml b/bin/files/push.yml new file mode 100644 index 00000000..286746b8 --- /dev/null +++ b/bin/files/push.yml @@ -0,0 +1,87 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + nodejs: + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: keepitsecret + POSTGRES_USER: testdb + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + env: + DATABASE_URL: postgres://testdb:keepitsecret@localhost:5432/testdb + steps: + - uses: textbook/take-action@nodejs + with: + node-version: 20 + - uses: textbook/take-action@playwright + - run: npm run lint + - run: npm run test:cover + env: + FORCE_COLOR: true + - run: npm run migration up + - run: npm run e2e + - run: npm run e2e:dev + docker: + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: keepitsecret + POSTGRES_USER: testdb + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: + - uses: textbook/take-action@nodejs + with: + node-version: 20 + - uses: textbook/take-action@playwright + - uses: docker/setup-buildx-action@v3 + - uses: docker/build-push-action@v5 + with: + load: true + push: false + tags: textbook/starter-kit:v2 + - id: env-file + run: | + echo 'DATABASE_URL=postgres://testdb:keepitsecret@localhost:5432/testdb' >> "$ENV_FILE" + echo 'LOG_LEVEL=debug' >> "$ENV_FILE" + echo 'PORT=4321' >> "$ENV_FILE" + echo 'NODE_ENV=docker' >> "$ENV_FILE" + echo "file=$ENV_FILE" >> "$GITHUB_OUTPUT" + env: + ENV_FILE: docker.env + - id: docker-run + run: | + echo "id=$(docker run \ + --detach \ + --env-file ${{ steps.env-file.outputs.file }} \ + --init \ + --network 'host' \ + textbook/starter-kit:v2)" >> $GITHUB_OUTPUT + - run: npx --yes wait-on --log --timeout 30000 http-get://localhost:4321 + - run: npm run e2e + env: + PLAYWRIGHT_BASE_URL: http://localhost:4321 + - if: always() && steps.docker-run.outputs.id + run: docker logs ${{ steps.docker-run.outputs.id }}