Run all tests in CI, don't fail build if not all pass #117
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: Build and test | |
| on: | |
| push: | |
| jobs: | |
| test: | |
| name: Build and test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| sql-version: ["2017-latest", "2019-latest", "2022-latest"] | |
| services: | |
| sqlserver: | |
| image: mcr.microsoft.com/mssql/server:${{ matrix.sql-version }} | |
| env: | |
| SA_PASSWORD: ${{ secrets.SA_PASSWORD }} | |
| ACCEPT_EULA: Y | |
| ports: | |
| - 1433:1433 | |
| options: >- | |
| --health-cmd "timeout 1 bash -c 'cat < /dev/null > /dev/tcp/localhost/1433'" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| --health-start-period 10s | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: npm run build | |
| - name: Run lint | |
| run: npm run lint | |
| - name: Check formatting | |
| run: npm run format:check | |
| - name: Install SQL Server command-line tools | |
| run: | | |
| curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc | |
| curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list | |
| sudo apt-get update | |
| sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18 unixodbc-dev | |
| echo "/opt/mssql-tools18/bin" >> $GITHUB_PATH | |
| - name: Create test database | |
| run: sqlcmd -S localhost -U sa -P "${SA_PASSWORD}" -C -Q "CREATE DATABASE testdb" | |
| env: | |
| SA_PASSWORD: ${{ secrets.SA_PASSWORD }} | |
| - name: Run tests | |
| run: npm run test | |
| continue-on-error: true | |
| env: | |
| SQLONFHIR_TEST_PATH: ./sqlonfhir/tests | |
| MSSQL_HOST: localhost | |
| MSSQL_DATABASE: testdb | |
| MSSQL_USER: sa | |
| MSSQL_PASSWORD: ${{ secrets.SA_PASSWORD }} | |
| - name: Upload test report artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-report-${{ matrix.sql-version }} | |
| path: out/test-report.json | |
| retention-days: 30 | |
| publish-report: | |
| name: Publish test report to GitHub Pages | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: always() | |
| permissions: | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Download all test reports | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: test-report-* | |
| path: test-reports | |
| - name: Prepare test reports for upload | |
| run: | | |
| BRANCH_NAME="${GITHUB_REF#refs/heads/}" | |
| BRANCH_DIR="${BRANCH_NAME}" | |
| mkdir -p "${BRANCH_DIR}" | |
| # Copy the latest SQL Server version report as the main report | |
| cp test-reports/test-report-2022-latest/test-report.json "${BRANCH_DIR}/test_report.json" | |
| # Also copy individual reports for each SQL Server version | |
| for version_dir in test-reports/test-report-*/; do | |
| version=$(basename "${version_dir}" | sed 's/test-report-//') | |
| cp "${version_dir}/test-report.json" "${BRANCH_DIR}/test_report_${version}.json" | |
| done | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: . | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |