Bump github/codeql-action from 2 to 4 #210
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: 'Unit Tests' | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| env: | |
| retention_days: 3 | |
| permissions: | |
| checks: write | |
| contents: read | |
| pull-requests: write | |
| security-events: write # required for SARIF upload | |
| actions: read | |
| jobs: | |
| tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full git history for version calculation | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v4.2.0 | |
| with: | |
| versionSpec: "6.3.x" | |
| - name: Determine Version | |
| id: version_step # step id used as a reference for output values | |
| uses: gittools/actions/gitversion/execute@v4.2.0 | |
| env: | |
| DOTNET_GITVERSION_TELEMETRY_OPTOUT: 1 | |
| with: | |
| configFilePath: ./GitVersion.yml | |
| - name: Extract version information | |
| id: extract-version | |
| run: | | |
| # Read GitVersion output and replace PullRequest with Patch | |
| VERSION="${{ steps.version_step.outputs.SemVer }}" | |
| # make 0.1.0-PullRequest99.190 to 0.1.0-Patch99.190 | |
| VERSION=$(echo "$VERSION" | sed 's/PullRequest/Patch/g') | |
| FULL_SEMVER="${{ steps.version_step.outputs.FullSemVer }}" | |
| MAJOR_MINOR_PATCH="${{ steps.version_step.outputs.MajorMinorPatch }}" | |
| GIT_HASH="${{ steps.version_step.outputs.Sha }}" | |
| GIT_TAG="${{ steps.version_step.outputs.PreReleaseTag }}" | |
| GIT_BRANCH="${{ steps.version_step.outputs.BranchName }}" | |
| COMMIT_COUNT="${{ steps.version_step.outputs.CommitsSinceVersionSource }}" | |
| BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| # Create version.txt content | |
| cat > version-$VERSION.txt << EOF | |
| version=$VERSION | |
| major_minor_patch=$MAJOR_MINOR_PATCH | |
| full_semver=$FULL_SEMVER | |
| git_hash=$GIT_HASH | |
| git_tag=$GIT_TAG | |
| git_branch=$GIT_BRANCH | |
| commit_count=$COMMIT_COUNT | |
| build_date=$BUILD_DATE | |
| EOF | |
| # Output version for other steps | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "MAJOR_MINOR_PATCH=$MAJOR_MINOR_PATCH" >> $GITHUB_OUTPUT | |
| echo "FULL_SEMVER=$FULL_SEMVER" >> $GITHUB_OUTPUT | |
| echo "GIT_HASH=$GIT_HASH" >> $GITHUB_OUTPUT | |
| echo "GIT_TAG=$GIT_TAG" >> $GITHUB_OUTPUT | |
| echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_OUTPUT | |
| echo "COMMIT_COUNT=$COMMIT_COUNT" >> $GITHUB_OUTPUT | |
| # Display version info | |
| echo "Generated version: $VERSION" | |
| echo "Major minor patch: $MAJOR_MINOR_PATCH" | |
| echo "Full semver: $FULL_SEMVER" | |
| echo "Git hash: $GIT_HASH" | |
| echo "Git branch: $GIT_BRANCH" | |
| echo "Commit count: $COMMIT_COUNT" | |
| echo "Build date: $BUILD_DATE" | |
| echo "version.txt content:" | |
| cat version-$VERSION.txt | |
| - name: Update project files with version | |
| run: | | |
| chmod +x scripts/updateVersion.sh | |
| bash scripts/updateVersion.sh | |
| - name: Upload version.txt as artifact | |
| uses: actions/upload-artifact@v4 | |
| continue-on-error: true | |
| with: | |
| name: version-info | |
| path: version-${{ steps.extract-version.outputs.VERSION }}.txt | |
| retention-days: ${{ env.retention_days }} | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 16 | |
| - run: npm ci | |
| - run: npm test | |
| - name: upload junit | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: junit | |
| path: junit.xml | |
| retention-days: ${{ env.retention_days }} | |
| # displays in summary page | |
| - name: Publish Test Report | |
| if: always() | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| with: | |
| files: junit.xml | |
| check_name: Test Results | |
| - run: npm run test:coverage | |
| - name: upload code coverage | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Report-CodeCoverage | |
| path: coverage | |
| retention-days: ${{ env.retention_days }} | |
| automerge: | |
| needs: tests | |
| name: Auto-merge PR if tests pass | |
| if: (github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' || github.actor == 'imgbot[bot]') && needs.tests.result == 'success' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Merge PR | |
| uses: peter-evans/enable-pull-request-automerge@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| merge-method: squash | |
| pull-request-number: ${{ github.event.pull_request.number }} |