unwrap any possibility of null to force values #72
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ["*"] | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'Dockerfile' | |
| - '**/*.cs' | |
| - '**/*.csproj' | |
| env: | |
| COVERAGE_THRESHOLD: 75 | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| checks: write | |
| packages: write | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set lowercase image name and tag | |
| uses: ./.github/actions/setup-image-metadata | |
| - name: Build Docker image (includes tests + coverage) | |
| run: docker build -t $IMAGE_NAME:$IMAGE_TAG . | |
| - name: Copy coverage report from container | |
| uses: ./.github/actions/copy-container-coverage | |
| with: | |
| container-tag: $IMAGE_NAME:$IMAGE_TAG | |
| target-path: coverage | |
| - name: Generate HTML and Summary.xml | |
| uses: ./.github/actions/generate-coverage-report | |
| with: | |
| input-dir: coverage | |
| output-dir: coverage-report | |
| - name: Enforce coverage threshold | |
| uses: ./.github/actions/enforce-coverage-threshold | |
| with: | |
| summary-path: coverage-report/Summary.xml | |
| threshold: ${{ env.COVERAGE_THRESHOLD }} | |
| - name: Upload coverage reports | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-html | |
| path: coverage-report | |
| - name: Publish unit test report | |
| uses: dorny/test-reporter@v2 | |
| with: | |
| name: Unit Tests | |
| path: coverage/**/*.trx | |
| reporter: dotnet-trx | |
| fail-on-error: true | |
| - name: Push image to GHCR | |
| run: docker push $IMAGE_NAME:$IMAGE_TAG | |
| # integration-tests: | |
| # needs: build-and-unit-test | |
| # runs-on: ubuntu-latest | |
| # env: | |
| # TEST_POSTGRES_DB: ratatest | |
| # TEST_POSTGRES_USER: testuser | |
| # TEST_POSTGRES_PASSWORD: testpass | |
| # steps: | |
| # - name: Checkout source code | |
| # uses: actions/checkout@v4 | |
| # - name: Log in to GitHub Container Registry | |
| # uses: docker/login-action@v3 | |
| # with: | |
| # registry: ghcr.io | |
| # username: ${{ github.actor }} | |
| # password: ${{ secrets.GITHUB_TOKEN }} | |
| # - name: Set lowercase image name and tag | |
| # run: | | |
| # echo "IMAGE_NAME=ghcr.io/${GITHUB_REPOSITORY,,}/ratatosk-api" >> $GITHUB_ENV | |
| # echo "IMAGE_TAG=ci" >> $GITHUB_ENV | |
| # - name: Pull the CI image | |
| # run: docker pull $IMAGE_NAME:$IMAGE_TAG | |
| # - name: Run integration tests | |
| # run: | | |
| # docker-compose -f docker-compose.test.yml --profile ci up --abort-on-container-exit --exit-code-from ratatosk-api-ci | |
| # - name: Tear down test environment | |
| # if: always() | |
| # run: docker-compose -f docker-compose.test.yml --profile ci down -v |