Skip to content

Commit 75693b2

Browse files
committed
added code
1 parent c6ac5f7 commit 75693b2

File tree

3 files changed

+89
-60
lines changed

3 files changed

+89
-60
lines changed

.github/workflows/coverage.yml

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
1-
name: Coverage report
1+
# name: Coverage report
22

3-
on:
4-
pull_request:
3+
# on:
4+
# pull_request:
55

6-
jobs:
7-
coverage:
8-
runs-on: ubuntu-latest
9-
steps:
10-
- name: Checkout code
11-
uses: actions/checkout@v2
6+
# jobs:
7+
# coverage:
8+
# runs-on: ubuntu-latest
9+
# steps:
10+
# - name: Checkout code
11+
# uses: actions/checkout@v2
1212

13-
- name: Set up Python
14-
uses: actions/setup-python@v3
15-
with:
16-
python-version: '3.10'
13+
# - name: Set up Python
14+
# uses: actions/setup-python@v3
15+
# with:
16+
# python-version: '3.10'
1717

18-
- name: Set up AWS credentials
19-
env:
20-
AWS_ACCESS_KEY_ID: "FOOBARKEY"
21-
AWS_SECRET_ACCESS_KEY: "FOOBARSECRET"
22-
run: |
23-
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
24-
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
18+
# - name: Set up AWS credentials
19+
# env:
20+
# AWS_ACCESS_KEY_ID: "FOOBARKEY"
21+
# AWS_SECRET_ACCESS_KEY: "FOOBARSECRET"
22+
# run: |
23+
# aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
24+
# aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
2525

26-
- name: Install dependencies
27-
run: |
28-
pip install poetry moto==4.2.11 coverage redis botocore==1.35.49 simplejson responses structlog fhir.resources jsonpath_ng pydantic==1.10.13 requests aws-lambda-typing cffi pyjwt boto3-stubs-lite[dynamodb]~=1.26.90
26+
# - name: Install dependencies
27+
# run: |
28+
# pip install poetry moto==4.2.11 coverage redis botocore==1.35.49 simplejson responses structlog fhir.resources jsonpath_ng pydantic==1.10.13 requests aws-lambda-typing cffi pyjwt boto3-stubs-lite[dynamodb]~=1.26.90
2929

30-
- name: Run unit tests and generate coverage report for immunisation-fhir-api
31-
run: |
32-
mkdir -p /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/backend/coverage_html_report
33-
coverage run -m unittest discover
34-
coverage report
35-
coverage xml -o /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/backend/coverage_html_report/test_coverage.xml
36-
working-directory: "/home/runner/work/immunisation-fhir-api/immunisation-fhir-api/backend"
37-
continue-on-error: true
30+
# - name: Run unit tests and generate coverage report for immunisation-fhir-api
31+
# run: |
32+
# mkdir -p /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/backend/coverage_html_report
33+
# coverage run -m unittest discover
34+
# coverage report
35+
# coverage xml -o /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/backend/coverage_html_report/test_coverage.xml
36+
# working-directory: "/home/runner/work/immunisation-fhir-api/immunisation-fhir-api/backend"
37+
# continue-on-error: true
3838

39-
- name: List coverage report file
40-
run: |
41-
ls -R /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/backend/coverage_html_report
39+
# - name: List coverage report file
40+
# run: |
41+
# ls -R /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/backend/coverage_html_report
4242

43-
- name: Aggregate coverage report
44-
run: |
45-
mkdir -p /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/coverage_html_report
46-
rm -rf /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/coverage_html_report/*
47-
mv /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/backend/coverage_html_report/test_coverage.xml /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/test_coverage.xml
43+
# - name: Aggregate coverage report
44+
# run: |
45+
# mkdir -p /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/coverage_html_report
46+
# rm -rf /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/coverage_html_report/*
47+
# mv /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/backend/coverage_html_report/test_coverage.xml /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/test_coverage.xml
4848

49-
- name: Commit and push coverage reports
50-
if: success()
51-
run: |
52-
git config --global user.name "github-actions[bot]"
53-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
54-
git fetch origin ${{ github.head_ref }}
55-
git checkout ${{ github.head_ref }}
56-
git pull origin ${{ github.head_ref }}
57-
git add /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/test_coverage.xml
58-
git commit -m "Add coverage index as XML format."
59-
git push origin ${{ github.head_ref }}
49+
# - name: Commit and push coverage reports
50+
# if: success()
51+
# run: |
52+
# git config --global user.name "github-actions[bot]"
53+
# git config --global user.email "github-actions[bot]@users.noreply.github.com"
54+
# git fetch origin ${{ github.head_ref }}
55+
# git checkout ${{ github.head_ref }}
56+
# git pull origin ${{ github.head_ref }}
57+
# git add /home/runner/work/immunisation-fhir-api/immunisation-fhir-api/test_coverage.xml
58+
# git commit -m "Add coverage index as XML format."
59+
# git push origin ${{ github.head_ref }}
6060

61-
- name: Upload coverage to SonarCloud
62-
env:
63-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
64-
uses: SonarSource/sonarcloud-github-action@v2
65-
with:
66-
args: >
67-
-Dsonar.projectKey=NHSDigital_immunisation-fhir-api
68-
-Dsonar.organization=nhsdigital
69-
-Dsonar.python.coverage.reportPaths=test_coverage.xml
61+
# - name: Upload coverage to SonarCloud
62+
# env:
63+
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
64+
# uses: SonarSource/sonarcloud-github-action@v2
65+
# with:
66+
# args: >
67+
# -Dsonar.projectKey=NHSDigital_immunisation-fhir-api
68+
# -Dsonar.organization=nhsdigital
69+
# -Dsonar.python.coverage.reportPaths=test_coverage.xml

.github/workflows/sonarcloud.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: SonarCloud
2+
3+
on:
4+
pull_request:
5+
6+
7+
jobs:
8+
sonarcloud:
9+
name: SonarCloud
10+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependency') }}
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16+
17+
- uses: ./.github/actions/composite-setup
18+
19+
- name: Run unittest with coverage
20+
run: |
21+
pip install poetry moto==4.2.11 coverage redis botocore==1.35.49 simplejson responses structlog fhir.resources jsonpath_ng pydantic==1.10.13 requests aws-lambda-typing cffi pyjwt boto3-stubs-lite[dynamodb]~=1.26.90
22+
poetry run coverage run --source=backend -m unittest discover
23+
poetry run coverage xml -o sonarcloud-coverage.xml
24+
25+
- name: SonarCloud Scan
26+
uses: SonarSource/sonarcloud-github-action@master
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
29+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ sonar.projectKey=NHSDigital_immunisation-fhir-api
33
sonar.organization=nhsdigital
44
sonar.host.url=https://sonarcloud.io
55
sonar.python.version=3.11
6-
sonar.python.coverage.reportPaths=test_coverage.xml
6+
sonar.python.coverage.reportPaths=sonarcloud-coverage.xml

0 commit comments

Comments
 (0)