Skip to content

Commit

Permalink
Merge pull request #4613 from bcgov/test
Browse files Browse the repository at this point in the history
v5.7.2-96.22 release
  • Loading branch information
JamesPayer authored Jan 23, 2025
2 parents 9939f5f + f8e1f86 commit 278c16b
Show file tree
Hide file tree
Showing 1,643 changed files with 340,458 additions and 17,417 deletions.
62 changes: 45 additions & 17 deletions .github/workflows/api-dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
# JOB to run change detection
check-changes:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
# Set job outputs to values from filter step
outputs:
backend: ${{ steps.filter.outputs.backend }}
Expand All @@ -24,12 +24,24 @@ jobs:
build-backend:
needs: check-changes
runs-on: ubuntu-22.04
if: ${{ needs.check-changes.outputs.backend == 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
services:
[
{ directory: ./source/backend/api, solution: "Pims.sln" },
{ directory: ./source/backend/proxy, solution: "Proxy.sln" },
{
directory: ./source/backend/scheduler,
solution: "Scheduler.sln",
},
]
env:
working-directory: ./source/backend
working-directory: ${{ matrix.services.directory }}
solution-name: ${{ matrix.services.solution }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_BRANCH: "${{github.ref}}"
GIT_BRANCH: "${{ github.ref }}"

steps:
- uses: actions/checkout@v4
Expand All @@ -45,19 +57,20 @@ jobs:
dotnet-version: "8.0.x"

- name: Install dependencies
run: dotnet restore
run: dotnet restore ${{env.solution-name}}
working-directory: ${{env.working-directory}}

- name: Install coverlet for code coverage
run: dotnet tool install -g coverlet.console --version 1.7.2
- name: Build
run: dotnet build ${{env.solution-name}} --configuration Release --no-restore
working-directory: ${{env.working-directory}}

- name: Build
run: dotnet build --configuration Release --no-restore
- name: Install coverlet for code coverage
run: dotnet tool install -g coverlet.console --version 1.7.2
working-directory: ${{env.working-directory}}

- name: Test
run: dotnet test --no-restore --verbosity normal
if: ${{ env.solution-name == 'Pims.sln' }}
run: dotnet test Pims.sln --no-restore --verbosity normal
working-directory: ${{env.working-directory}}

# For future reference, if we have N test projects the flow of events would be:
Expand All @@ -84,46 +97,54 @@ jobs:
#
# The final `coverage.opencover.xml` is the one we want
- name: Generate code coverage
working-directory: ${{env.working-directory}}/tests/unit
if: ${{ env.solution-name == 'Pims.sln' }}
working-directory: ${{env.working-directory}}/../tests/unit
run: |
pwd
mkdir -p TestResults
rm -rf api/TestResults
rm -rf dal/TestResults
rm -rf mockdal/TestResults
cd api
dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore
dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore > out.txt
ls
cat out.txt
mv TestResults/*/* ../TestResults/
cd ..
cd dal
dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore
ls
mv TestResults/*/* ../TestResults/
cd ..
cd mockdal
dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore
ls
mv TestResults/*/* ../TestResults/
cd ..
head TestResults/coverage.opencover.xml
- name: Save PR number and scan results
if: ${{ env.solution-name == 'Pims.sln' }}
run: |
mkdir -p ./pr
echo ${{ github.event.pull_request.number }} > ./pr/NR
cp ${{env.working-directory}}/tests/unit/TestResults/coverage.opencover.xml ./pr
cp ${{env.working-directory}}/../tests/unit/TestResults/coverage.opencover.xml ./pr
- uses: actions/upload-artifact@v4
if: ${{ env.solution-name == 'Pims.sln' }}
with:
name: pr-codecov
path: pr/

- name: SonarScanner for .NET 8 with pull request decoration support
id: scan
uses: highbyte/[email protected]
if: ${{ github.event_name == 'push' }}
if: ${{ github.event_name == 'push' && env.solution-name == 'Pims.sln' }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
dotnetBuildArguments: ${{env.working-directory}}
dotnetTestArguments: ${{env.working-directory}} --logger trx --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
dotnetBuildArguments: ${{env.working-directory}}/${{ env.solution-name }}
dotnetTestArguments: ${{env.working-directory}}/${{ env.solution-name }} --logger trx --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
# Optional extra command arguments the the SonarScanner 'begin' command
sonarBeginArguments: /d:sonar.cs.opencover.reportsPaths="**/TestResults/**/coverage.opencover.xml" -d:sonar.cs.vstest.reportsPaths="**/TestResults/*.trx" -d:sonar.qualitygate.wait=true
# The key of the SonarQube project
Expand All @@ -132,7 +153,14 @@ jobs:
sonarProjectName: PIMS-API
# The SonarQube server URL. For SonarCloud, skip this setting.
sonarHostname: ${{secrets.SONAR_URL}}

post-build:
needs: build-backend
runs-on: ubuntu-22.04
env:
working-directory: ./source/backend
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_BRANCH: "${{github.ref}}"
steps:
# Send notifications only if MS_TEAMS_NOTIFY_URL secret has been set
- name: Failure notification to Teams Channel
env:
Expand Down
87 changes: 42 additions & 45 deletions .github/workflows/app-logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ on:
pull_request:
branches: [master, test, dev]


jobs:

build:

name: build-logging
if: github.event.ref == 'refs/heads/master' || github.event.ref == 'refs/heads/test' || github.event.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
env:
SLEEP_TIME: 60
STORAGE_TYPE: Amazon_S3
Expand All @@ -32,44 +29,44 @@ jobs:
working-directory: ./openshift/4.0/templates/Logging

steps:
- uses: actions/checkout@v4
- name: Set ENV variable
run: |
if [[ ${{github.event.ref}} == 'refs/heads/test' ]]; then
echo "FRONTEND_APP_NAME=pims-app-test" >> $GITHUB_ENV
echo "API_NAME=pims-api-test" >> $GITHUB_ENV
elif [[ ${{github.event.ref}} == 'refs/heads/master' ]]; then
echo "FRONTEND_APP_NAME=pims-app-uat" >> $GITHUB_ENV
echo "API_NAME=pims-api-uat" >> $GITHUB_ENV
echo "PROJECT_NAMESPACE=3cd915-test" >> $GITHUB_ENV
else
echo "FRONTEND_APP_NAME=pims-app" >> $GITHUB_ENV
echo "API_NAME=pims-api" >> $GITHUB_ENV
fi
- name: Build the pims-logging docker-compose stack
run: docker-compose -f docker-compose.yml up -d
working-directory: ${{env.working-directory}}
- name: Sleep for 180 seconds
uses: jakejarvis/wait-action@master
with:
time: '180s'
- name: Check Extracted Logs
run: |
docker cp pims-logging:/logging/. .
exitcode=$(docker inspect pims-logging --format='{{.State.ExitCode}}')
if [[ "$(ls -A pims* 2>/dev/null | wc -l)" != "0" ]]; then
ls -A pims* && rm -f pims*
elif [[ $exitcode == 0 ]]; then
echo "Info: No log captured between sleep time"
else
echo "There's an error capturing pims logs" && exit 1
fi
- name: Check running containers
run: docker ps -a
- name: Check pims-logging logs
if: always()
run: docker logs pims-logging
- name: Stop containers
if: always()
run: docker-compose -f "docker-compose.yml" down
working-directory: ${{env.working-directory}}
- uses: actions/checkout@v4
- name: Set ENV variable
run: |
if [[ ${{github.event.ref}} == 'refs/heads/test' ]]; then
echo "FRONTEND_APP_NAME=pims-app-test" >> $GITHUB_ENV
echo "API_NAME=pims-api-test" >> $GITHUB_ENV
elif [[ ${{github.event.ref}} == 'refs/heads/master' ]]; then
echo "FRONTEND_APP_NAME=pims-app-uat" >> $GITHUB_ENV
echo "API_NAME=pims-api-uat" >> $GITHUB_ENV
echo "PROJECT_NAMESPACE=3cd915-test" >> $GITHUB_ENV
else
echo "FRONTEND_APP_NAME=pims-app" >> $GITHUB_ENV
echo "API_NAME=pims-api" >> $GITHUB_ENV
fi
- name: Build the pims-logging docker-compose stack
run: docker-compose -f docker-compose.yml up -d
working-directory: ${{env.working-directory}}
- name: Sleep for 180 seconds
uses: jakejarvis/wait-action@master
with:
time: "180s"
- name: Check Extracted Logs
run: |
docker cp pims-logging:/logging/. .
exitcode=$(docker inspect pims-logging --format='{{.State.ExitCode}}')
if [[ "$(ls -A pims* 2>/dev/null | wc -l)" != "0" ]]; then
ls -A pims* && rm -f pims*
elif [[ $exitcode == 0 ]]; then
echo "Info: No log captured between sleep time"
else
echo "There's an error capturing pims logs" && exit 1
fi
- name: Check running containers
run: docker ps -a
- name: Check pims-logging logs
if: always()
run: docker logs pims-logging
- name: Stop containers
if: always()
run: docker-compose -f "docker-compose.yml" down
working-directory: ${{env.working-directory}}
4 changes: 2 additions & 2 deletions .github/workflows/app-react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
# JOB to run change detection
check-changes:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
# Set job outputs to values from filter step
outputs:
frontend: ${{ steps.filter.outputs.frontend }}
Expand All @@ -25,7 +25,7 @@ jobs:
build-frontend:
needs: check-changes
if: ${{ needs.check-changes.outputs.frontend == 'true' }}
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
env:
CI: true
working-directory: ./source/frontend
Expand Down
Loading

0 comments on commit 278c16b

Please sign in to comment.