1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/.github/workflows/integration-tests-pr.yaml
Christopher Fenner e11de9dbeb
chore(ci): add yamllint action (#2774)
* chore(ci): add yamllint action

* Create .yamllint.yml

* Update verify-yaml.yml

* Update verify-yaml.yml

* Update verify-yaml.yml

* Update verify-yaml.yml

* Update verify-yaml.yml

* correct yaml format

* correct yamllint findings

* disable truthy rule

* add pattern for workflows yamls

* fix c&p issue
2021-04-22 12:55:35 +02:00

98 lines
5.4 KiB
YAML

name: Integration Tests (Pull Request)
on:
issue_comment:
types: [created]
jobs:
consumer-tests:
name: Consumer Tests
runs-on: ubuntu-latest
if: github.event.comment.body == '/it' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER')
steps:
- name: get pull request url
id: pullrequest
run: echo "::set-output name=pullrequest::$(curl ${{ github.event.comment.issue_url }} | jq '.pull_request.url' | sed 's/\"//g')"
- name: get branch name
id: branchname
run: echo "::set-output name=branchname::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.ref' | sed 's/\"//g')"
- name: get repository
id: repository
run: echo "::set-output name=repository::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.repo.full_name' | sed 's/\"//g')"
- name: checkout
uses: actions/checkout@v2
with:
repository: ${{ steps.repository.outputs.repository }}
ref: ${{ steps.branchname.outputs.branchname }}
- uses: actions/setup-java@v1
with:
java-version: '11'
- name: install groovy
run: sudo apt-get update && sudo apt-get install groovy -y
- name: setup git
run: git config --global user.email "piper-testing-bot@example.com" && git config --global user.name "piper-testing-bot"
- name: run consumer tests
run: cd consumer-test && groovy consumerTestController.groovy
env:
REPOSITORY_UNDER_TEST: ${{ steps.repository.outputs.repository }}
BRANCH_NAME: ${{ steps.branchname.outputs.branchname }}
BUILD_WEB_URL: https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}
INTEGRATION_TEST_VOTING_TOKEN: ${{ secrets.INTEGRATION_TEST_VOTING_TOKEN }}
CX_INFRA_IT_CF_USERNAME: ${{ secrets.CX_INFRA_IT_CF_USERNAME }}
CX_INFRA_IT_CF_PASSWORD: ${{ secrets.CX_INFRA_IT_CF_PASSWORD }}
NEO_DEPLOY_USERNAME: ${{ secrets.NEO_DEPLOY_USERNAME }}
NEO_DEPLOY_PASSWORD: ${{ secrets.NEO_DEPLOY_PASSWORD }}
CX_INFRA_IT_TMS_UPLOAD: ${{ secrets.CX_INFRA_IT_TMS_UPLOAD }}
go-integration-tests:
name: Go Integration Tests
runs-on: ubuntu-latest
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')
steps:
- name: get pull request url
id: pullrequest
run: echo "::set-output name=pullrequest::$(curl ${{ github.event.comment.issue_url }} | jq '.pull_request.url' | sed 's/\"//g')"
- name: get branch name
id: branchname
run: echo "::set-output name=branchname::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.ref' | sed 's/\"//g')"
- name: get repository
id: repository
run: echo "::set-output name=repository::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.repo.full_name' | sed 's/\"//g')"
- name: checkout
uses: actions/checkout@v2
with:
repository: ${{ steps.repository.outputs.repository }}
ref: ${{ steps.branchname.outputs.branchname }}
- name: get commit id
id: commitId
run: echo "::set-output name=commitId::$(git log --format=%H -n 1)"
- name: update status
run: |
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}}'
- uses: actions/setup-go@v1
with:
go-version: '1.15.x'
- name: build
env:
CGO_ENABLED: 0
# with `-tags release` we ensure that shared test utilities won't end up in the binary
run: go build -o piper -tags release
- name: test
env:
PIPER_INTEGRATION_GITHUB_TOKEN: ${{secrets.PIPER_INTEGRATION_GITHUB_TOKEN}}
PIPER_INTEGRATION_SONAR_TOKEN: ${{secrets.PIPER_INTEGRATION_SONAR_TOKEN}}
run: go test -tags=integration -timeout 20m ./integration/...
- name: update status
if: success()
run: |
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}}'
- name: update status
if: cancelled() || failure()
run: |
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}}'