Skip to content

Fix/234638/add blue header for recommendations #3488

Fix/234638/add blue header for recommendations

Fix/234638/add blue header for recommendations #3488

Workflow file for this run

name: Code PR Check
on:
push:
branches: ["main", "development"]
paths:
- "src/**"
- "tests/**"
pull_request:
branches: ["main", "development"]
paths:
- "src/**"
- "tests/**"
- ".github/workflows/code-pr-check.yml"
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true
env:
DOTNET_VERSION: ${{ vars.DOTNET_VERSION }}
jobs:
lint-code:
name: Lint & Commit
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'pull_request' }}
permissions:
contents: write
pull-requests: write
checks: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
cache: false
- name: Lint plan-technology-for-your-school.sln solution
run: dotnet format plan-technology-for-your-school.sln
- name: Commit and push changes if necessary
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
if [[ `git status --porcelain` ]]; then
git add src/*
git add tests/*
git commit -m "chore: Linted code for plan-technology-for-your-school.sln solution"
git push
else
echo 'No linting changes'
fi
build-test-web-app:
name: Build and run unit tests
runs-on: ubuntu-22.04
if: ${{ always() && ( github.event_name == 'pull_request' && needs.lint-code.result == 'success' ) || ( github.event_name == 'push' && needs.lint-code.result == 'skipped' ) }}
needs: [lint-code]
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Install dotnet coverage
run: dotnet tool install --global dotnet-coverage --version 17.9.3
- name: Install SonarCloud scanners
run: dotnet tool install --global dotnet-sonarscanner
- name: Install latest JDK
uses: actions/setup-java@v4
with:
distribution: "microsoft"
java-version: "17"
- name: Start SonarCloud scanner
run: |
dotnet-sonarscanner begin \
/k:"DFE-Digital_plan-technology-for-your-school" \
/o:"dfe-digital" \
/d:sonar.login="${{ secrets.SONAR_TOKEN }}" \
/d:sonar.host.url="https://sonarcloud.io" \
/d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml \
/d:sonar.coverage.exclusions=**/Program.cs,**/gulpfile.js,**/wwwroot/**,**/Dfe.PlanTech.Web.SeedTestData/** \
/d:sonar.issue.ignore.multicriteria=e1 \
/d:sonar.issue.ignore.multicriteria.e1.ruleKey=csharpsquid:S6602 \
/d:sonar.issue.ignore.multicriteria.e1.resourceKey=src/**/*.cs \
/d:sonar.scanner.scanAll=false
- name: Build web app
uses: ./.github/actions/build-dotnet-app
with:
dotnet_version: ${{ env.DOTNET_VERSION }}
solution_filename: plan-technology-for-your-school.sln
- name: Run unit tests
uses: ./.github/actions/run-unit-tests
with:
solution_filename: plan-technology-for-your-school.sln
- name: Merge test results
run: dotnet-coverage merge -f xml -o "coverage.xml" -s "coverage.settings.xml" -r coverage.cobertura.xml
- name: End SonarCloud Scanner
run: dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: coverage.xml
build-database-upgrader:
name: Build database upgrader
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Build database upgrader
uses: ./.github/actions/build-dotnet-app
with:
dotnet_version: ${{ env.DOTNET_VERSION }}
solution_filename: Dfe.PlanTech.DatabaseUpgrader.sln
run-javascript-tests:
runs-on: ubuntu-22.04
name: Run javascript tests
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "latest"
- name: Install Dependencies
working-directory: ./tests/Dfe.PlanTech.Web.Node.UnitTests/
run: npm install
- name: Run the tests
working-directory: ./tests/Dfe.PlanTech.Web.Node.UnitTests/
run: npm test
- name: Test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: JEST Tests # Name of the check run which will be created
path: ./tests/Dfe.PlanTech.Web.Node.UnitTests/junit.xml # Path to test results
reporter: jest-junit # Format of test results