Merge pull request #77 from pagopa/PAGOPA-2017 #366
This file contains 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: Code Review | |
# Controls when the workflow will run | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- synchronize | |
- reopened | |
push: | |
branches: | |
- main | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
PROJECT_KEY: pagopa_pagopa-receipt-pdf-helpdesk | |
permissions: | |
id-token: write | |
contents: read | |
deployments: write | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
code-review: | |
name: Code Review | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 | |
- name: Code Review | |
env: | |
TZ: "Europe/Rome" | |
uses: ./.github/maven_code_review | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
sonar_token: ${{ secrets.SONAR_TOKEN }} | |
project_key: ${{env.PROJECT_KEY}} | |
jdk_version: 17 | |
maven_version: 3.9.3 | |
coverage_exclusions: "**/config/*,**/*Mock*,**/model/**,**/entity/*,**/producer/**,**/enumeration/**" | |
cpd_exclusions: "**/model/**,**/entity/*" | |
smoke-test: | |
name: Smoke Test | |
runs-on: ubuntu-latest | |
environment: | |
name: dev | |
steps: | |
- name: Checkout | |
id: checkout | |
uses: actions/checkout@1f9a0c22da41e6ebfa534300ef656657ea2c6707 | |
- name: Login | |
id: login | |
# from https://github.com/Azure/login/commits/master | |
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 | |
with: | |
client-id: ${{ secrets.CD_CLIENT_ID }} | |
tenant-id: ${{ secrets.TENANT_ID }} | |
subscription-id: ${{ secrets.SUBSCRIPTION_ID }} | |
- name: Run Service on Docker | |
shell: bash | |
id: run_service_docker | |
run: | | |
cd ./docker | |
chmod +x ./run_docker.sh | |
./run_docker.sh local | |
- name: Run Integration Tests | |
shell: bash | |
id: run_integration_test | |
run: | | |
export CUCUMBER_PUBLISH_TOKEN=${{ secrets.CUCUMBER_PUBLISH_TOKEN }} | |
export RECEIPTS_COSMOS_CONN_STRING='${{ secrets.RECEIPTS_COSMOS_CONN_STRING }}' | |
export BIZEVENTS_COSMOS_CONN_STRING='${{ secrets.BIZEVENTS_COSMOS_CONN_STRING }}' | |
export RECEIPTS_STORAGE_CONN_STRING='${{ secrets.RECEIPTS_STORAGE_CONN_STRING }}' | |
export SUBKEY='${{ secrets.SUBKEY }}' | |
cd ./integration-test | |
chmod +x ./run_integration_test.sh | |
./run_integration_test.sh local | |
- name: Teardown integration tests | |
shell: bash | |
id: run_teardown | |
if: ${{ always() }} | |
run: | | |
export CUCUMBER_PUBLISH_TOKEN=${{ secrets.CUCUMBER_PUBLISH_TOKEN }} | |
export RECEIPTS_COSMOS_CONN_STRING='${{ secrets.RECEIPTS_COSMOS_CONN_STRING }}' | |
export BIZEVENTS_COSMOS_CONN_STRING='${{ secrets.BIZEVENTS_COSMOS_CONN_STRING }}' | |
export RECEIPTS_STORAGE_CONN_STRING='${{ secrets.RECEIPTS_STORAGE_CONN_STRING }}' | |
cd ./integration-test | |
chmod +x ./run_teardown.sh | |
./run_teardown.sh local | |
delete_github_deployments: | |
runs-on: ubuntu-latest | |
needs: smoke-test | |
if: ${{ always() }} | |
steps: | |
- name: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJSON(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- name: Delete Previous deployments | |
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6 | |
env: | |
SHA_HEAD: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.sha}} | |
with: | |
script: | | |
const { SHA_HEAD } = process.env | |
const deployments = await github.rest.repos.listDeployments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
sha: SHA_HEAD | |
}); | |
await Promise.all( | |
deployments.data.map(async (deployment) => { | |
await github.rest.repos.createDeploymentStatus({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
deployment_id: deployment.id, | |
state: 'inactive' | |
}); | |
return github.rest.repos.deleteDeployment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
deployment_id: deployment.id | |
}); | |
}) | |
); |