Skip to content

Merge branch 'refs/heads/main' into use-caching-in-github-actions #40

Merge branch 'refs/heads/main' into use-caching-in-github-actions

Merge branch 'refs/heads/main' into use-caching-in-github-actions #40

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
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 Consumer Api
uses: docker/build-push-action@v5
with:
context: .
file: ConsumerApi/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
tags: consumer-api
load: true
#outputs: type=registry,dest=localhost:6000/consumer-api
# - 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