wip #54
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: Docker Test | |
on: | |
push: | |
branches-ignore: | |
- "main" | |
tags-ignore: | |
- "**" | |
jobs: | |
container-test-builds: | |
name: Build ${{matrix.tag}} Container | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- dockerfile: ConsumerApi/Dockerfile | |
tag: consumer-api | |
- dockerfile: AdminApi/src/AdminApi/Dockerfile | |
tag: admin-ui | |
- dockerfile: Modules/Devices/src/Devices.AdminCli/Dockerfile | |
tag: seed-client | |
- dockerfile: DatabaseMigrator/Dockerfile | |
tag: database-migrator | |
- dockerfile: EventHandlerService/src/EventHandlerService/Dockerfile | |
tag: event-handler-service | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: "npm" | |
cache-dependency-path: "**/package-lock.json" | |
- name: Setup Docker | |
uses: docker/setup-buildx-action@v3 | |
- name: Setup NuGet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
#cache: true | |
- name: Cache Image | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-${{ matrix.tag }}-cache | |
key: buildx-${{ matrix.tag }}-cache-${{ hashFiles(matrix.dockerfile) }} | |
restore-keys: | | |
buildx-${{ matrix.tag }}-cache- | |
# - id: cache | |
# name: Cache Docker | |
# uses: actions/cache@v3 | |
# with: | |
# path: /tmp/docker-registry | |
# key: ${{ runner.os }}-registry-${{ hashFiles('**/Dockerfile', './.ci/docker-compose.test*.yml') }} | |
# restore-keys: | | |
# ${{ runner.os }}-registry- | |
#- name: Cache npm dependencies | |
# uses: actions/cache@v3 | |
# with: | |
# path: | | |
# ./runtime/node_modules | |
# key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
# restore-keys: | | |
# ${{ runner.os }}-npm- | |
- name: Install script dependencies | |
run: npm install --prefix ./.ci | |
#- name: Clear Docker Container | |
# run: python .ci/integrationTest.py postgres down | |
#- name: Build Docker | |
# run: python .ci/integrationTest.py postgres build | |
#- name: Startup Docker | |
# run: python .ci/integrationTest.py postgres up -d | |
#- name: Build Docker | |
# uses: docker/build-push-action@v5 | |
# with: | |
# context: . | |
# file: ./.ci/docker-compose.postgres.yml | |
# push: false | |
# cache-from: type=gha | |
# cache-to: type=gha,mode=max | |
#- name: Run Tests | |
# run: python .ci/integrationTest.py build | |
# - name: Run local registry | |
# run: docker run -d -p 6000:5000 --restart=always --name registry -v /tmp/docker-registry:/var/lib/registry registry:2 && npx wait-on tcp:6000 | |
- name: Build Container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ${{ matrix.dockerfile }} | |
cache-from: type=local,src=/tmp/.buildx-${{ matrix.tag }}-cache | |
cache-to: type=local,mode=max,dest=/tmp/.buildx-${{ matrix.tag }}-cache-new | |
#cache-from: type=gha | |
#cache-to: type=gha,mode=max | |
tags: ${{ matrix.tag }} | |
load: false | |
outputs: type=docker,dest=/tmp/${{ matrix.tag }}.tar | |
#outputs: type=registry,dest=localhost:6000/consumer-api | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docker-${{ matrix.tag }} | |
path: /tmp/${{ matrix.tag }}.tar | |
retention-days: 1 | |
# - name: Build Admin Api | |
# uses: docker/build-push-action@v5 | |
# with: | |
# context: . | |
# file: AdminApi/src/AdminApi/Dockerfile | |
# cache-from: type=gha | |
# cache-to: type=gha,mode=min | |
# tags: admin-ui | |
# load: true | |
# #outputs: type=registry,dest=localhost:6000/admin-ui | |
# | |
# - name: Build Seed Client | |
# uses: docker/build-push-action@v5 | |
# with: | |
# context: . | |
# file: Modules/Devices/src/Devices.AdminCli/Dockerfile | |
# cache-from: type=gha | |
# cache-to: type=gha,mode=min | |
# tags: seed-client | |
# load: true | |
# #outputs: type=registry,dest=localhost:6000/seed-client | |
# | |
# - name: Run integration tests | |
# run: ./.ci/integrationTest.postgres.sh | |
# - name: Push ConsumerAPI to local registry | |
# run: docker tag consumer-api localhost:6000/consumer-api && docker push localhost:6000/consumer-api || true | |
#if: steps.cache.outputs.cache-hit != 'true' | |
# - name: Push AdminUI to local registry | |
# run: docker tag admin-ui localhost:6000/admin-ui && docker push localhost:6000/admin-ui || true | |
#if: steps.cache.outputs.cache-hit != 'true' | |
# - name: Push Seed Client to local registry | |
# run: docker tag seed-client localhost:6000/seed-client && docker push localhost:6000/seed-client || true | |
#if: steps.cache.outputs.cache-hit != 'true' | |
- name: Save Docker Logs | |
if: failure() | |
run: docker compose -f ./.ci/docker-compose.test.yml -f ./.ci/docker-compose.test.postgres.yml logs > docker-log.txt | |
- name: Archive logs | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: integration-test-postgres-docker-logs | |
path: docker-log.txt | |
env: | |
DOTNET_CONSOLE_ANSI_COLOR: true | |
# Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-${{ matrix.tag }}-cache | |
mv /tmp/.buildx-${{ matrix.tag }}-cache-new /tmp/.buildx-${{ matrix.tag }}-cache | |
run-tests: | |
name: Run tests | |
runs-on: ubuntu-latest | |
needs: container-test-builds | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: "npm" | |
cache-dependency-path: "**/package-lock.json" | |
- name: Setup Docker | |
uses: docker/setup-buildx-action@v3 | |
- name: Setup NuGet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
- name: Install script dependencies | |
run: npm install --prefix ./.ci | |
- name: Download Docker images | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp | |
pattern: docker-* | |
merge-multiple: true | |
- name: Load Docker images | |
run: | | |
docker load --input /tmp/consumer-api.tar | |
docker load --input /tmp/admin-ui.tar | |
docker load --input /tmp/seed-client.tar | |
docker load --input /tmp/database-migrator.tar | |
docker load --input /tmp/event-handler-service.tar | |
- name: Run integration tests | |
run: ./.ci/integrationTest.postgres.sh |