chore: pushed images to registry so they are built only once #75
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Run Tests | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
# TODO - Optimize. Build images only once. | |
# For example, webapp-next is built 3 times now: | |
# In build job and once for each backend when testing e2e | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
service: | |
[ | |
backend-rest-go, | |
backend-rest-js, | |
webapp-htmx-go, | |
webapp-nextjs, | |
e2e-cypress, | |
bdd-go, | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Build Docker image | |
run: | | |
docker build -t ${{ matrix.service }} ${{ matrix.service }} \ | |
--tag kadai/${{ matrix.service }}:${GITHUB_SHA} | |
- name: Push Docker image | |
run: | | |
docker push kadai/${{ matrix.service }}:${GITHUB_SHA} | |
api: | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
runner: [bdd-go] | |
backend: [go, js] | |
db: [inmemory, mongo] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: extractions/setup-just@v2 | |
- uses: KengoTODA/actions-setup-docker-compose@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: echo "${{ secrets.DOT_ENV }}" > .env | |
- name: Run Acceptance - API tests | |
run: just test-${{ matrix.runner }}-${{ matrix.backend }}-${{ matrix.db }} | |
e2e: | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
runner: [cypress] | |
frontend: [nextjs, htmx-go] | |
backend: [go, js] | |
db: [inmemory, mongo] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: extractions/setup-just@v2 | |
- uses: KengoTODA/actions-setup-docker-compose@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: echo "${{ secrets.DOT_ENV }}" > .env | |
- name: Run E2E tests | |
run: just test-${{ matrix.runner }}-${{ matrix.frontend }}-${{ matrix.backend }}-${{ matrix.db }} | |
- name: Upload test screenshots | |
uses: actions/[email protected] | |
with: | |
name: e2e-screenshots-${{ matrix.e2e_runner }}-${{ matrix.frontend }}-${{ matrix.backend }}-${{ matrix.db }} | |
path: e2e-cypress/cypress/screenshots |