Skip to content

wip

wip #46

Workflow file for this run

name: Docker Test
on:
push:
branches-ignore:
- "main"
tags-ignore:
- "**"
jobs:
docker-integration-test-postgres:
name: Run Cached Integration Tests (on Postgres)
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 Docker
# uses: actions/cache@v3
# with:
# path: /tmp/.buildx-cache
# key: ${{ runner.os }}-buildx-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-buildx-
# - 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 Containers
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.dockerfile }}
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
# - 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-cache
# mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-solution:
name: Build Solution
runs-on: ubuntu-latest
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 NuGet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install script dependencies
run: npm install --prefix ./.ci
- name: Restore Solution
run: dotnet restore "Backbone.sln"
- name: Build Solution
run: dotnet build --no-restore "Backbone.sln"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: solution
path: ./**/bin/Debug/net8.0/
run-tests:
name: Run tests
runs-on: ubuntu-latest
needs:
- docker-integration-test-postgres
- build-solution
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: Download Built solution
uses: actions/download-artifact@v4
with:
name: solution
path: .
- 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