forked from SAP/jenkins-library
-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (89 loc) · 5.36 KB
/
integration-tests-pr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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 "[email protected]" && 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.18.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 25m ./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}}'