diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/create-release-tag.yml similarity index 88% rename from .github/workflows/continuous-integration.yml rename to .github/workflows/create-release-tag.yml index 780e37712..9186891dd 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/create-release-tag.yml @@ -1,11 +1,13 @@ -name: Create Release -on: push +name: Create Release Tag +on: + push: + branches: + - master jobs: create_release: - name: build + name: Create Release runs-on: ubuntu-latest - if: github.ref == 'refs/heads/master' steps: - name: Checkout uses: actions/checkout@v5 @@ -40,4 +42,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ env.SPEC_VERSION }} - release_name: ${{ env.SPEC_VERSION }} \ No newline at end of file + release_name: ${{ env.SPEC_VERSION }} diff --git a/.github/workflows/pr-jira-link.yaml b/.github/workflows/pr-jira-link.yaml new file mode 100644 index 000000000..2156df254 --- /dev/null +++ b/.github/workflows/pr-jira-link.yaml @@ -0,0 +1,29 @@ +name: Create PR JIRA Link +on: + pull_request: + types: [opened, synchronize] + +jobs: + link-ticket: + runs-on: ubuntu-latest + env: + BRANCH_NAME: ${{ github.event.pull_request.head.ref }} + steps: + - name: Check ticket name conforms to requirements + run: echo $BRANCH_NAME | grep -i -E -q "(ved-[0-9]+)|(dependabot\/)" + continue-on-error: true + + - name: Grab ticket name + run: echo "TICKET_NAME=$(echo $BRANCH_NAME | grep -i -o '\(ved-[0-9]\+\)' | tr '[:lower:]' '[:upper:]')" >> $GITHUB_ENV + continue-on-error: true + + - name: Comment on PR with link to JIRA ticket + if: contains(env.TICKET_NAME, 'VED-') + continue-on-error: true + uses: unsplash/comment-on-pr@a9bf050e744c8282dee4bb0dbcf063186d8316c4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: | + This branch is working on a ticket in the NHS England VED JIRA Project. Here's a handy link to the ticket: + # [${{ env.TICKET_NAME }}](https://nhsd-jira.digital.nhs.uk/browse/${{ env.TICKET_NAME}}) diff --git a/.github/workflows/pr-lint.yaml b/.github/workflows/pr-lint.yaml deleted file mode 100644 index 25d61bb6f..000000000 --- a/.github/workflows/pr-lint.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: PR Quality Check -on: - pull_request: - types: [opened] - -jobs: - link-ticket: - runs-on: ubuntu-latest - steps: - - name: Check ticket name conforms to requirements - run: echo ${{ github.event.pull_request.head.ref }} | grep -i -E -q "(amb-[0-9]+)|(ambspii-[0-9]+)|(adz-[0-9]+)|(ved-[0-9]+)|(dependabot\/)" - continue-on-error: true - - - name: Grab ticket name - if: contains(github.event.pull_request.head.ref, 'amb-') || contains(github.event.pull_request.head.ref, 'AMB-') || contains(github.event.pull_request.head.ref, 'ambspii-') || contains(github.event.pull_request.head.ref, 'AMBSPII-') || contains(github.event.pull_request.head.ref, 'adz-') || contains(github.event.pull_request.head.ref, 'ADZ-') || contains(github.event.pull_request.head.ref, 'ved-') || contains(github.event.pull_request.head.ref, 'VED-') - run: echo "TICKET_NAME=$(echo ${{ github.event.pull_request.head.ref }} | grep -i -o '\(amb-[0-9]\+\)\|\(ambspii-[0-9]\+\)\|\(adz-[0-9]\+\)\|\(ved-[0-9]\+\)' | tr '[:lower:]' '[:upper:]')" >> $GITHUB_ENV - continue-on-error: true - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - - - name: Comment on PR with link to JIRA ticket - if: contains(github.event.pull_request.head.ref, 'amb-') || contains(github.event.pull_request.head.ref, 'AMB-') || contains(github.event.pull_request.head.ref, 'ambspii-') || contains(github.event.pull_request.head.ref, 'AMBSPII-') || contains(github.event.pull_request.head.ref, 'adz-') || contains(github.event.pull_request.head.ref, 'ADZ-') || contains(github.event.pull_request.head.ref, 'ved-') || contains(github.event.pull_request.head.ref, 'VED-') - continue-on-error: true - uses: unsplash/comment-on-pr@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - msg: | - This branch is working on a ticket in the NHS England VED JIRA Project. Here's a handy link to the ticket: - # [${{ env.TICKET_NAME }}](https://nhsd-jira.digital.nhs.uk/browse/${{ env.TICKET_NAME}}) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/quality-checks.yml similarity index 88% rename from .github/workflows/sonarcloud.yml rename to .github/workflows/quality-checks.yml index ea2e171c7..2996f3a8f 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/quality-checks.yml @@ -1,4 +1,4 @@ -name: SonarCloud +name: Quality Checks on: push: @@ -12,14 +12,40 @@ env: LAMBDA_PATH: ${{ github.workspace }}/lambdas jobs: - sonarcloud: - name: SonarCloud + lint: + name: Lint specification and Python projects runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 + + - name: Install poetry + run: pip install poetry==2.1.4 + + # Base linting requires 3.8 due to APIM package dependencies. See root README for details under linting. + # Consider upgrading this and poetry deps if we move away from Azure DevOps to using the Proxygen tool. + - uses: actions/setup-python@v5 + with: + python-version: 3.8 + cache: 'poetry' + + - uses: actions/setup-node@v5 with: - fetch-depth: 0 + node-version: '23.11.0' + cache: 'npm' + + - name: Install linting dependencies + run: make install-node && poetry install --no-root + + - name: Lint + run: make lint + + testcoverage_and_sonarcloud: + name: Test Coverage and SonarCloud + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 - name: Install poetry run: pip install poetry==2.1.4 @@ -184,7 +210,7 @@ jobs: fi - name: SonarCloud Scan - uses: SonarSource/sonarqube-scan-action@master + uses: SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/README.md b/README.md index b208a47ab..f3fbfee3e 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ It is not necessary to activate the virtual environment (using `source .venv/bin The root-level virtual environment is primarily used for linting, as we create separate virtual environments for each folder that contains Lambda functions. Steps: 1. Follow instructions above to [install dependencies](#install-dependencies) & [set up a virtual environment](#setting-up-a-virtual-environment-with-poetry). -**Note: While this project uses Python 3.10 (e.g. for Lambdas), the NHSDigital/api-management-utils repository — which orchestrates setup and linting — defaults to Python 3.8. +**Note: While this project uses Python 3.11 (e.g. for Lambdas), the NHSDigital/api-management-utils repository — which orchestrates setup and linting — defaults to Python 3.8. The linting command is executed from within that repo but calls the Makefile in this project, so be aware of potential Python version mismatches when running or debugging locally or in the pipeline.** 2. Run `make lint`. This will: - Check the linting of the API specification yaml. diff --git a/README.specification.md b/README.specification.md index 6a235923f..e5dfb7bd2 100644 --- a/README.specification.md +++ b/README.specification.md @@ -102,8 +102,8 @@ To get started developing your API use this template repo alongside guidance pro This folder contains templates that can be customised for items such as opening pull requests or issues within the repo `/.github/workflows`: This folder contains templates for github action workflows such as: -- `pr-lint.yaml`: This workflow template shows how to link Pull Request's to Jira tickets and runs when a pull request is opened. -- `continuous-integration.yml`: This workflow template shows how to publish a Github release when pushing to master. +- `pr-jira-link.yaml`: This workflow template links Pull Requests to Jira tickets and runs when a pull request is opened. +- `create-release-tag.yml`: This workflow template shows how to publish a Github release when pushing to master. #### `/azure`: diff --git a/pyproject.toml b/pyproject.toml index d3c2419f1..de4894e79 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,5 @@ [project] +name = "immunisation-fhir-api" python = "^3.8" [tool.poetry]