-
Notifications
You must be signed in to change notification settings - Fork 205
125 lines (109 loc) · 3.89 KB
/
api-tests.yml
File metadata and controls
125 lines (109 loc) · 3.89 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: 'API Tests'
on:
# NOTE: no action on `push` and `pull_request` since the API tests need to be run
# against a container that has the latest changes from your code. Therefore, the
# PMM_SERVER_IMAGE should either be the one from your feature build or the local
# devcontainer. One more scenario is when we want to run the API tests on dev-latest
# to see if the tests are in a good shape.
# That said, this workflow is mostly a convenience if you prefer Github to Jenkins.
# https://github.com/Percona-Lab/jenkins-pipelines/blob/master/pmm/pmm3-api-tests.groovy
workflow_dispatch:
inputs:
PMM_SERVER_IMAGE:
description: "PMM Server image version"
default: "ghcr.io/percona/pmm:3-dev-container"
required: true
type: string
workflow_call:
inputs:
BRANCH:
description: "The branch to pull API tests from"
default: "v3"
required: true
type: string
PMM_SERVER_IMAGE:
description: "PMM Server image version"
default: "ghcr.io/percona/pmm:3-dev-container"
required: true
type: string
permissions:
contents: read
jobs:
test:
name: Tests
runs-on: ubuntu-22.04
env:
PMM_URL: https://admin:admin@127.0.0.1
BRANCH: ${{ github.event.inputs.BRANCH || 'v3' }}
PMM_SERVER_IMAGE: ${{ github.event.inputs.PMM_SERVER_IMAGE }}
steps:
- name: Check out code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ env.BRANCH }}
- name: Login to docker.io registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Run PMM Server
run: |
cat <<-EOF > compose.yml
services:
pmm-server:
image: ${{ env.PMM_SERVER_IMAGE }}
container_name: pmm-server
environment:
- PMM_DEBUG=1
- PMM_DEV_PERCONA_PLATFORM_ADDRESS=https://check-dev.percona.com
ports:
- 443:8443
volumes:
- pmm-data:/srv
- ./managed/testdata/checks:/srv/checks
volumes:
pmm-data:
name: pmm-data
EOF
# Run it and wait until it's healthy
docker compose -f compose.yml up -d --wait --wait-timeout=100
- name: Build the test image
shell: bash
run: |
echo "Make sure to set the context to the root of the repository."
docker buildx build -f api-tests/Dockerfile -t percona/pmm-api-tests .
- name: Run compose up for test DBs
shell: bash
run: |
pushd api-tests
docker compose up test_db # no daemon mode
popd
- name: Check connectivity to PMM Server
shell: bash
run: curl -kf ${{env.PMM_URL}}/ping
- name: Run API tests
shell: bash
run: |
docker run \
-e PMM_SERVER_URL=${{env.PMM_URL}} \
-e PMM_RUN_UPDATE_TEST=0 \
-e PMM_RUN_ADVISOR_TESTS=0 \
-e PMM_SERVER_INSECURE_TLS=1 \
--name pmm-api-tests \
--network host \
percona/pmm-api-tests
- name: Get PMM logs
if: ${{ failure() }}
run: curl -k ${{env.PMM_URL}}/logs.zip --output ${{ github.workspace }}/logs.zip || true
- name: Upload the logs on failure
if: ${{ failure() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: "logs.zip"
path: ${{ github.workspace }}/logs.zip
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
echo "----- ENVIRONMENT VARIABLES -----"
env | sort