Merge branch 'main' into nmshdb-124-extension-of-the-audit-log #5696
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: Test | |
on: | |
push: | |
branches-ignore: | |
- "main" | |
tags-ignore: | |
- "**" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
adminui-checks: | |
runs-on: ubuntu-latest | |
name: Run Admin UI Checks | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Run Checks | |
run: ./.ci/aui/runChecks.sh | |
adminui-flutter-checks: | |
runs-on: ubuntu-latest | |
name: Run Admin UI Flutter Checks | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Flutter | |
uses: subosito/[email protected] | |
- name: Run checks | |
run: ./.ci/aui/runFlutterChecks.sh | |
check-formatting: | |
runs-on: ubuntu-latest | |
name: Check Formatting | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
cache: "npm" | |
cache-dependency-path: "**/package.json" | |
- name: Cache npm dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ./runtime/node_modules | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: ${{ runner.os }}-npm- | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: "8.x" | |
- name: Cache NuGet packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
restore-keys: ${{ runner.os }}-nuget- | |
- name: Check formatting | |
run: ./.ci/checkFormatting.sh | |
unit-test: | |
runs-on: ubuntu-latest | |
name: Run Unit Tests | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
cache: "npm" | |
cache-dependency-path: "**/package.json" | |
- name: Cache npm dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ./runtime/node_modules | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: ${{ runner.os }}-npm- | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: "8.x" | |
- name: Cache NuGet packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
restore-keys: ${{ runner.os }}-nuget- | |
- name: Run tests | |
run: ./.ci/test.sh | |
env: | |
DOTNET_CONSOLE_ANSI_COLOR: true | |
image-test-builds: | |
name: Build ${{matrix.image}} Image | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- dockerfile: ConsumerApi/Dockerfile | |
image: consumer-api | |
- dockerfile: AdminApi/src/AdminApi/Dockerfile | |
image: admin-ui | |
- dockerfile: Modules/Devices/src/Devices.AdminCli/Dockerfile | |
image: admin-cli | |
- dockerfile: DatabaseMigrator/Dockerfile | |
image: database-migrator | |
- dockerfile: EventHandlerService/src/EventHandlerService/Dockerfile | |
image: event-handler-service | |
- dockerfile: Modules/Files/src/Files.Jobs.SanityCheck/Dockerfile | |
image: files-sanity-check | |
- dockerfile: Jobs/src/Job.IdentityDeletion/Dockerfile | |
image: identity-deletion-jobs | |
- dockerfile: SseServer/src/SseServer/Dockerfile | |
image: sse-server | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
cache: "npm" | |
cache-dependency-path: "**/package-lock.json" | |
- name: Setup Docker | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver: docker-container | |
- name: Setup NuGet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
- name: Cache Image | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-${{ matrix.image }}-cache | |
key: buildx-${{ matrix.image }}-cache-${{ hashFiles(matrix.dockerfile) }} | |
restore-keys: buildx-${{ matrix.image }}-cache- | |
- name: Build Image | |
uses: docker/build-push-action@v6 | |
env: | |
DOCKER_BUILD_SUMMARY: false | |
with: | |
context: . | |
file: ${{ matrix.dockerfile }} | |
cache-from: type=local,src=/tmp/.buildx-${{ matrix.image }}-cache | |
cache-to: type=local,mode=max,dest=/tmp/.buildx-${{ matrix.image }}-cache-new | |
outputs: type=docker,dest=/tmp/${{ matrix.image }}.tar | |
tags: ${{ matrix.image }}:0.0.1 | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docker-${{ matrix.image }} | |
path: /tmp/${{ matrix.image }}.tar | |
retention-days: 1 | |
# 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.image }}-cache | |
mv /tmp/.buildx-${{ matrix.image }}-cache-new /tmp/.buildx-${{ matrix.image }}-cache | |
integration-test: | |
name: Run ${{matrix.test-project.display-name}} integration tests on ${{matrix.database}} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
database: [sqlserver, postgres] | |
test-project: | |
- display-name: admin-api | |
path: AdminApi/test/AdminApi.Tests.Integration | |
- display-name: consumer-api | |
path: ConsumerApi.Tests.Integration | |
- display-name: identity-deletion-job | |
path: Jobs/test/Job.IdentityDeletion.Tests.Integration | |
needs: image-test-builds | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
cache: "npm" | |
cache-dependency-path: "**/package-lock.json" | |
- name: Setup NuGet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
- name: Cache NuGet packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
restore-keys: ${{ runner.os }}-nuget- | |
- name: Download cached Docker images | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp | |
pattern: docker-* | |
merge-multiple: true | |
- name: Load Docker images and build test code | |
run: | | |
{ | |
./.ci/loadDockerImages.sh | |
} & | |
{ | |
dotnet restore Backbone.sln | |
# The following two lines are for the identity deletion job only | |
mv Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json ./Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json.bak | |
cp .ci/appsettings.override.${{matrix.database}}.local.json Jobs/test/Job.IdentityDeletion.Tests.Integration/appsettings.override.json | |
dotnet build --no-restore Backbone.sln | |
} | |
wait | |
- name: Start compose stack | |
run: | | |
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml down -v | |
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml up --no-build --wait -d | |
- name: Run integration tests | |
run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false;summary.includeSkippedTests=false;summary.includePassedTests=false" ${{matrix.test-project.path}} | |
env: | |
ADMIN_API_BASE_ADDRESS: "http://localhost:5173" | |
CONSUMER_API_BASE_ADDRESS: "http://localhost:5000" | |
- name: Save Docker Logs | |
if: failure() | |
run: docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml logs > logs.txt | |
- name: Archive logs | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{matrix.test-project.display-name}}-${{matrix.database}} | |
path: logs.txt | |
transport-test: | |
name: Run transport tests on ${{matrix.database}} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
database: [sqlserver, postgres] | |
needs: image-test-builds | |
steps: | |
- name: Checkout backbone repository | |
uses: actions/checkout@v4 | |
with: | |
path: backbone | |
- name: Checkout runtime repository | |
uses: actions/checkout@v4 | |
with: | |
repository: nmshd/runtime | |
path: runtime | |
ref: release/v5 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
cache: "npm" | |
cache-dependency-path: "**/package-lock.json" | |
- name: Download cached Docker images | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp | |
pattern: docker-* | |
merge-multiple: true | |
- name: Load Docker images | |
run: ./backbone/.ci/loadDockerImages.sh | |
- name: Start compose stack | |
run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml up --no-build --wait -d | |
- name: Install runtime dependencies | |
working-directory: ./runtime | |
run: npm install | |
- name: Run transport Tests | |
working-directory: ./runtime/packages/transport | |
env: | |
NMSHD_TEST_BASEURL: http://localhost:5000 | |
NMSHD_TEST_CLIENTID: test | |
NMSHD_TEST_CLIENTSECRET: test | |
NMSHD_TEST_BASEURL_ADMIN_API: http://localhost:5173 | |
NMSHD_TEST_ADMIN_API_KEY: test | |
run: npm run test:local:lokijs | |
- name: Save Docker Logs | |
if: failure() | |
run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml logs > logs.txt | |
- name: Archive logs | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: transport-test-${{matrix.database}}-docker-logs | |
path: logs.txt | |
- name: Stop compose stack | |
run: docker compose -f ./backbone/.ci/compose.test.${{matrix.database}}.yml -f ./backbone/.ci/compose.test.yml down | |
build-helm-chart: | |
name: Build Helm Chart | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install script dependencies | |
run: npm install --prefix ./.ci | |
- name: Build Helm Chart | |
run: ./.ci/helm/buildChart.js | |
env: | |
VERSION: 0.0.0 | |
validate-licenses: | |
name: Validate Open Source Licenses | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Dotnet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
- name: Install nuget-licenses tool | |
run: dotnet tool install --global nuget-license | |
- name: Show Allowed Licenses | |
run: cat ./.ci/allowedLicenses.json | |
- name: Show Ignored Packages | |
run: cat ./.ci/ignoredPackages.json | |
- name: Restore Solution | |
run: dotnet restore ./Backbone.sln | |
- name: Validate Licenses | |
run: nuget-license --input ./Backbone.sln --allowed-license-types ./.ci/allowedLicenses.json --ignored-packages ./.ci/ignoredPackages.json --output table --error-only |