2022-09-19 12:47:13 +02:00
|
|
|
name: Integration tests
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
- it/**
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
start:
|
|
|
|
name: Start
|
2022-09-20 18:29:21 +02:00
|
|
|
outputs:
|
2022-09-22 19:12:13 +02:00
|
|
|
go_version: ${{ steps.go_version.outputs.go_version }}
|
2022-09-20 18:29:21 +02:00
|
|
|
sha: ${{ steps.sha.outputs.sha }}
|
2022-09-20 08:24:04 +02:00
|
|
|
runs-on: ubuntu-latest
|
2022-09-19 12:47:13 +02:00
|
|
|
steps:
|
2023-09-21 16:29:13 +02:00
|
|
|
- uses: styfle/cancel-workflow-action@0.11.0
|
2023-09-21 16:11:11 +02:00
|
|
|
- uses: actions/checkout@v4
|
2022-09-22 19:12:13 +02:00
|
|
|
- name: Get GO version
|
|
|
|
id: go_version
|
|
|
|
run: |
|
2023-02-03 11:21:24 +02:00
|
|
|
echo "go_version=$(cat go.mod | grep go | head -1 | awk '{print $2}')" >> "$GITHUB_OUTPUT"
|
2022-09-20 18:29:21 +02:00
|
|
|
- name: Get commit SHA
|
|
|
|
id: sha
|
|
|
|
run: |
|
2023-02-03 11:21:24 +02:00
|
|
|
echo "sha=$(git log --format=%H -n 1)" >> "$GITHUB_OUTPUT"
|
2022-09-19 12:47:13 +02:00
|
|
|
- name: Update status
|
|
|
|
run: |
|
2022-09-20 08:24:04 +02:00
|
|
|
curl \
|
|
|
|
--location \
|
2022-09-20 18:29:21 +02:00
|
|
|
--request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.sha.outputs.sha }}' \
|
2022-09-20 08:24:04 +02:00
|
|
|
-H 'Content-Type: application/json' \
|
2022-09-19 12:47:13 +02:00
|
|
|
--data '{"state": "pending",
|
|
|
|
"context": "Go / integration-tests",
|
2022-09-20 08:24:04 +02:00
|
|
|
"target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' \
|
2022-09-19 12:47:13 +02:00
|
|
|
-H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
|
|
|
|
|
2022-09-20 08:24:04 +02:00
|
|
|
build_piper:
|
|
|
|
name: Build Piper
|
2022-09-19 12:47:13 +02:00
|
|
|
needs:
|
|
|
|
- start
|
2022-09-20 08:24:04 +02:00
|
|
|
runs-on: ubuntu-latest
|
2022-09-22 19:12:13 +02:00
|
|
|
timeout-minutes: 5
|
2022-09-19 12:47:13 +02:00
|
|
|
steps:
|
2023-09-21 16:11:11 +02:00
|
|
|
- uses: actions/checkout@v4
|
2022-09-19 12:47:13 +02:00
|
|
|
with:
|
2022-09-20 18:29:21 +02:00
|
|
|
ref: ${{ needs.start.outputs.sha }}
|
2023-07-05 10:14:28 +02:00
|
|
|
- uses: actions/setup-go@v4
|
2022-09-19 12:47:13 +02:00
|
|
|
with:
|
2022-09-22 19:12:13 +02:00
|
|
|
go-version: ${{ needs.start.outputs.go_version }}
|
2022-09-20 08:24:04 +02:00
|
|
|
- name: Build
|
|
|
|
# with `-tags release` we ensure that shared test utilities won't end up in the binary
|
|
|
|
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o piper -tags release
|
|
|
|
- name: Upload Piper binary
|
|
|
|
if: success()
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: piper
|
|
|
|
path: piper
|
2022-09-19 12:47:13 +02:00
|
|
|
|
2022-09-20 08:24:04 +02:00
|
|
|
build_integration_tests:
|
|
|
|
name: Build integration tests
|
2022-09-22 19:12:13 +02:00
|
|
|
outputs:
|
|
|
|
matrix: ${{ steps.matrix.outputs.matrix }}
|
2022-09-19 12:47:13 +02:00
|
|
|
needs:
|
|
|
|
- start
|
2022-09-20 08:24:04 +02:00
|
|
|
runs-on: ubuntu-latest
|
2022-09-22 19:12:13 +02:00
|
|
|
timeout-minutes: 5
|
2022-09-19 12:47:13 +02:00
|
|
|
steps:
|
2023-09-21 16:11:11 +02:00
|
|
|
- uses: actions/checkout@v4
|
2022-09-19 12:47:13 +02:00
|
|
|
with:
|
2022-09-20 18:29:21 +02:00
|
|
|
ref: ${{ needs.start.outputs.sha }}
|
2023-07-05 10:14:28 +02:00
|
|
|
- uses: actions/setup-go@v4
|
2022-09-19 12:47:13 +02:00
|
|
|
with:
|
2022-09-22 19:12:13 +02:00
|
|
|
go-version: ${{ needs.start.outputs.go_version }}
|
2022-09-19 12:47:13 +02:00
|
|
|
- name: Build
|
2022-09-20 08:24:04 +02:00
|
|
|
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go test -c -o integration_tests -tags integration ./integration/...
|
2022-09-22 19:12:13 +02:00
|
|
|
- name: Form integration tests run matrix
|
|
|
|
if: success()
|
|
|
|
id: matrix
|
|
|
|
run: |
|
2023-02-03 11:21:24 +02:00
|
|
|
echo "matrix=$(go run .github/workflows/parse_integration_test_list.go -file ./integration/github_actions_integration_test_list.yml)" >> "$GITHUB_OUTPUT"
|
2022-09-20 08:24:04 +02:00
|
|
|
- name: Upload integration tests binary
|
2022-09-19 12:47:13 +02:00
|
|
|
if: success()
|
2022-09-20 08:24:04 +02:00
|
|
|
uses: actions/upload-artifact@v3
|
2022-09-19 12:47:13 +02:00
|
|
|
with:
|
2022-09-20 08:24:04 +02:00
|
|
|
name: integration_tests
|
|
|
|
path: integration_tests
|
2022-09-19 12:47:13 +02:00
|
|
|
|
2022-09-20 08:24:04 +02:00
|
|
|
run_integration_tests:
|
|
|
|
name: Run integration tests
|
2022-09-19 12:47:13 +02:00
|
|
|
needs:
|
|
|
|
- build_piper
|
2022-09-20 08:24:04 +02:00
|
|
|
- build_integration_tests
|
2022-12-12 09:55:38 +02:00
|
|
|
- start
|
2022-09-19 12:47:13 +02:00
|
|
|
strategy:
|
|
|
|
fail-fast: true
|
2022-09-22 19:12:13 +02:00
|
|
|
matrix: ${{ fromJson(needs.build_integration_tests.outputs.matrix) }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 10
|
2022-09-19 12:47:13 +02:00
|
|
|
steps:
|
2023-09-21 16:11:11 +02:00
|
|
|
- uses: actions/checkout@v4
|
2022-09-19 12:47:13 +02:00
|
|
|
with:
|
2022-09-20 18:29:21 +02:00
|
|
|
ref: ${{ needs.start.outputs.sha }}
|
2023-07-05 10:14:28 +02:00
|
|
|
- uses: actions/setup-go@v4
|
2022-09-19 12:47:13 +02:00
|
|
|
with:
|
2022-09-22 19:12:13 +02:00
|
|
|
go-version: ${{ needs.start.outputs.go_version }}
|
2022-09-19 12:47:13 +02:00
|
|
|
- name: Download Piper binary
|
2022-09-20 08:24:04 +02:00
|
|
|
uses: actions/download-artifact@v3
|
2022-09-19 12:47:13 +02:00
|
|
|
with:
|
|
|
|
name: piper
|
2022-09-20 08:24:04 +02:00
|
|
|
- name: Download integration tests binary
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: integration_tests
|
|
|
|
path: ./integration/
|
2022-09-19 12:47:13 +02:00
|
|
|
- name: Run test
|
2022-09-22 19:12:13 +02:00
|
|
|
env:
|
|
|
|
PIPER_INTEGRATION_GITHUB_TOKEN: ${{secrets.PIPER_INTEGRATION_GITHUB_TOKEN}}
|
|
|
|
PIPER_INTEGRATION_SONAR_TOKEN: ${{secrets.PIPER_INTEGRATION_SONAR_TOKEN}}
|
2023-01-19 11:02:56 +02:00
|
|
|
PIPER_tmsServiceKey: ${{secrets.PIPER_TMSSERVICEKEY}}
|
2022-09-20 08:24:04 +02:00
|
|
|
run: |
|
|
|
|
chmod +x piper
|
|
|
|
cd ./integration
|
|
|
|
chmod +x integration_tests
|
2022-09-22 19:12:13 +02:00
|
|
|
./integration_tests -test.v -test.run ${{ matrix.run }}
|
2022-09-19 12:47:13 +02:00
|
|
|
|
2022-09-22 19:12:13 +02:00
|
|
|
finish:
|
2022-09-20 08:24:04 +02:00
|
|
|
name: Finish
|
|
|
|
if: always() && needs.start.result == 'success'
|
2022-09-19 12:47:13 +02:00
|
|
|
needs:
|
2022-09-20 08:24:04 +02:00
|
|
|
- start
|
2022-09-19 12:47:13 +02:00
|
|
|
- build_piper
|
2022-09-20 08:24:04 +02:00
|
|
|
- build_integration_tests
|
|
|
|
- run_integration_tests
|
|
|
|
runs-on: ubuntu-latest
|
2022-09-19 12:47:13 +02:00
|
|
|
steps:
|
|
|
|
- name: Update status
|
|
|
|
run: |
|
2022-09-20 08:24:04 +02:00
|
|
|
if [[ "${{ needs.run_integration_tests.result }}" == "success" ]]
|
2022-09-19 12:47:13 +02:00
|
|
|
then
|
2022-09-20 08:24:04 +02:00
|
|
|
curl \
|
|
|
|
--location \
|
2022-09-20 18:29:21 +02:00
|
|
|
--request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ needs.start.outputs.sha }}' \
|
2022-09-20 08:24:04 +02:00
|
|
|
-H 'Content-Type: application/json' \
|
2022-09-19 12:47:13 +02:00
|
|
|
--data '{"state": "success",
|
|
|
|
"context": "Go / integration-tests",
|
2022-09-20 08:24:04 +02:00
|
|
|
"target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' \
|
|
|
|
-H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}' && \
|
|
|
|
exit 0
|
2022-09-19 12:47:13 +02:00
|
|
|
else
|
2022-09-20 08:24:04 +02:00
|
|
|
curl \
|
|
|
|
--location \
|
2022-09-20 18:29:21 +02:00
|
|
|
--request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ needs.start.outputs.sha }}' \
|
2022-09-20 08:24:04 +02:00
|
|
|
-H 'Content-Type: application/json' \
|
2022-09-19 12:47:13 +02:00
|
|
|
--data '{"state": "failure",
|
|
|
|
"context": "Go / integration-tests",
|
2022-09-20 08:24:04 +02:00
|
|
|
"target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' \
|
|
|
|
-H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}' && \
|
|
|
|
exit 1
|
2022-09-19 12:47:13 +02:00
|
|
|
fi
|