-
Notifications
You must be signed in to change notification settings - Fork 4
101 lines (87 loc) · 3.47 KB
/
test-e2e-service-templates.yml
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
name: "E2E: Templates"
on:
workflow_call:
inputs:
without-cache:
type: boolean
default: false
required: false
env:
TEST_PARALLELISM: 16
TEST_PARALLELISM_PKG: 1
# Required for aws-actions/configure-aws-credentials using OIDC, assume role
permissions:
id-token: write
contents: read
jobs:
test:
name: test
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Setup line endings
run: git config --global core.autocrlf false
- name: Change default TEST_COVERAGE when on main branch
if: github.ref == 'refs/heads/main'
run: echo "TEST_COVERAGE=true" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go, tools and caching
uses: ./.github/actions/go-setup
with:
build-type: e2e-tests-templates
without-cache: ${{ inputs.without-cache }}
cache-s3-bucket: ${{ vars.CACHE_S3_BUCKET }}
- name: Set TEST_KBC_PROJECTS_FILE entries
uses: ./.github/actions/export-kbc-projects
with:
secrets: ${{ toJSON(secrets) }}
- name: Start etcd database
run: |
set -Eeuo pipefail
docker compose run -d --rm --publish 2379:2379 etcd
sudo echo "127.0.0.1 etcd" | sudo tee -a /etc/hosts
- name: Run E2E tests
shell: bash
run: |
set -eo pipefail
# Build binary for test without external inputs
env -i \
TERM="$TERM" \
HOME="$HOME" \
PATH="$PATH" \
BUILD_TARGET_PATH="$TEST_BINARY_TEMPLATES_API" \
make build-templates-api
touch -d '1970-01-01T00:00:01' "$TEST_BINARY_TEMPLATES_API"
# Calculate binary hash, it invalidates tests cache
export TEST_BINARY_TEMPLATES_API_HASH=`cat "$TEST_BINARY_TEMPLATES_API" | $MD5_COMMAND | cut -d " " -f1`
echo "Binary hash: $TEST_BINARY_TEMPLATES_API_HASH"
# ENVs can affect test caching, make sure to only run tests with expected ENVs
env -i \
TERM="$TERM" \
HOME="$HOME" \
PATH="$PATH" \
DATADOG_ENABLED="false" \
TEMPLATES_ETCD_ENDPOINT="etcd:2379" \
TEMPLATES_ETCD_USERNAME="root" \
TEMPLATES_ETCD_PASSWORD="toor" \
TEST_BINARY_TEMPLATES_API="$TEST_BINARY_TEMPLATES_API" \
TEST_BINARY_TEMPLATES_API_HASH="$TEST_BINARY_TEMPLATES_API_HASH" \
TEST_PARALLELISM="$TEST_PARALLELISM" \
TEST_PARALLELISM_PKG="$TEST_PARALLELISM_PKG" \
TEST_COVERAGE="false" \
TEST_CREATE_OUT_DIR="false" \
TEST_KBC_PROJECTS_LOCK_HOST="$TEST_KBC_PROJECTS_LOCK_HOST" \
TEST_KBC_PROJECTS_LOCK_PASSWORD="$TEST_KBC_PROJECTS_LOCK_PASSWORD" \
TEST_KBC_PROJECTS_FILE="$TEST_KBC_PROJECTS_FILE" \
make tests-templates-api
env:
TEST_BINARY_TEMPLATES_API: "${{ runner.temp }}/test-build-templates-api"
TEST_KBC_PROJECTS_LOCK_HOST: ${{ vars.TEST_KBC_PROJECTS_LOCK_HOST }}
TEST_KBC_PROJECTS_LOCK_PASSWORD: ${{ secrets.TEST_KBC_PROJECTS_LOCK_PASSWORD }}
TEST_KBC_PROJECTS_FILE: '${{ github.workspace }}/${{ vars.TEST_KBC_PROJECTS_FILE }}'
- name: Validate OpenAPI3 definition
uses: swaggerexpert/swagger-editor-validate@v1
with:
definition-file: internal/pkg/service/templates/api/openapi/openapi3.yaml