github.com/jaylevin/jenkins-library@v1.230.4/.github/workflows/integration-tests-pr.yaml (about) 1 name: Integration Tests (Pull Request) 2 3 on: 4 issue_comment: 5 types: [created] 6 7 jobs: 8 9 consumer-tests: 10 name: Consumer Tests 11 12 runs-on: ubuntu-latest 13 if: github.event.comment.body == '/it' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER') 14 15 steps: 16 - name: get pull request url 17 id: pullrequest 18 run: echo "::set-output name=pullrequest::$(curl ${{ github.event.comment.issue_url }} | jq '.pull_request.url' | sed 's/\"//g')" 19 - name: get branch name 20 id: branchname 21 run: echo "::set-output name=branchname::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.ref' | sed 's/\"//g')" 22 - name: get repository 23 id: repository 24 run: echo "::set-output name=repository::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.repo.full_name' | sed 's/\"//g')" 25 - name: checkout 26 uses: actions/checkout@v2 27 with: 28 repository: ${{ steps.repository.outputs.repository }} 29 ref: ${{ steps.branchname.outputs.branchname }} 30 - uses: actions/setup-java@v1 31 with: 32 java-version: '11' 33 - name: install groovy 34 run: sudo apt-get update && sudo apt-get install groovy -y 35 - name: setup git 36 run: git config --global user.email "piper-testing-bot@example.com" && git config --global user.name "piper-testing-bot" 37 - name: run consumer tests 38 run: cd consumer-test && groovy consumerTestController.groovy 39 env: 40 REPOSITORY_UNDER_TEST: ${{ steps.repository.outputs.repository }} 41 BRANCH_NAME: ${{ steps.branchname.outputs.branchname }} 42 BUILD_WEB_URL: https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }} 43 INTEGRATION_TEST_VOTING_TOKEN: ${{ secrets.INTEGRATION_TEST_VOTING_TOKEN }} 44 CX_INFRA_IT_CF_USERNAME: ${{ secrets.CX_INFRA_IT_CF_USERNAME }} 45 CX_INFRA_IT_CF_PASSWORD: ${{ secrets.CX_INFRA_IT_CF_PASSWORD }} 46 NEO_DEPLOY_USERNAME: ${{ secrets.NEO_DEPLOY_USERNAME }} 47 NEO_DEPLOY_PASSWORD: ${{ secrets.NEO_DEPLOY_PASSWORD }} 48 CX_INFRA_IT_TMS_UPLOAD: ${{ secrets.CX_INFRA_IT_TMS_UPLOAD }} 49 50 go-integration-tests: 51 name: Go Integration Tests 52 53 runs-on: ubuntu-latest 54 if: (github.event.comment.body == '/it' || github.event.comment.body == '/it-go') && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER') 55 56 steps: 57 - name: get pull request url 58 id: pullrequest 59 run: echo "::set-output name=pullrequest::$(curl ${{ github.event.comment.issue_url }} | jq '.pull_request.url' | sed 's/\"//g')" 60 - name: get branch name 61 id: branchname 62 run: echo "::set-output name=branchname::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.ref' | sed 's/\"//g')" 63 - name: get repository 64 id: repository 65 run: echo "::set-output name=repository::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.repo.full_name' | sed 's/\"//g')" 66 - name: checkout 67 uses: actions/checkout@v2 68 with: 69 repository: ${{ steps.repository.outputs.repository }} 70 ref: ${{ steps.branchname.outputs.branchname }} 71 - name: get commit id 72 id: commitId 73 run: echo "::set-output name=commitId::$(git log --format=%H -n 1)" 74 - name: update status 75 run: | 76 curl --location --request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commitId.outputs.commitId }}' -H 'Content-Type: application/json' --data '{"state": "pending", "context": "Go / integration-tests", "target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' -H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}' 77 - uses: actions/setup-go@v1 78 with: 79 go-version: '1.18.x' 80 - name: build 81 env: 82 CGO_ENABLED: 0 83 # with `-tags release` we ensure that shared test utilities won't end up in the binary 84 run: go build -o piper -tags release 85 - name: test 86 env: 87 PIPER_INTEGRATION_GITHUB_TOKEN: ${{secrets.PIPER_INTEGRATION_GITHUB_TOKEN}} 88 PIPER_INTEGRATION_SONAR_TOKEN: ${{secrets.PIPER_INTEGRATION_SONAR_TOKEN}} 89 run: go test -tags=integration -timeout 25m ./integration/... 90 - name: update status 91 if: success() 92 run: | 93 curl --location --request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commitId.outputs.commitId }}' -H 'Content-Type: application/json' --data '{"state": "success", "context": "Go / integration-tests", "target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' -H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}' 94 - name: update status 95 if: cancelled() || failure() 96 run: | 97 curl --location --request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commitId.outputs.commitId }}' -H 'Content-Type: application/json' --data '{"state": "failure", "context": "Go / integration-tests", "target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' -H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'