-
Notifications
You must be signed in to change notification settings - Fork 8
149 lines (133 loc) · 6.39 KB
/
integration-sample-app-qa.yml
File metadata and controls
149 lines (133 loc) · 6.39 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: "Sample Apps"
permissions:
contents: read
on:
# To conserve resources we only run tests against main in PRs
pull_request:
branches:
- main
jobs:
check-for-changed-sample-apps:
name: Check for changed sample apps
runs-on: ubuntu-latest
outputs:
changed-sample-apps: ${{ steps.filtered-changes.outputs.filtered-dirs }}
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
fetch-depth: 0
persist-credentials: false
- name: Get changed sample apps
id: changed-files
uses: step-security/changed-files@95b56dadb92a30ca9036f16423fd3c088a71ee94 # v46.0.5
with:
path: sample-apps
dir_names: true
dir_names_exclude_current_dir: true
dir_names_max_depth: 1
matrix: true
- name: Filter out windows and macos
id: filtered-changes
run: |
ALL_CHANGED_DIRS='${{ steps.changed-files.outputs.all_changed_files }}'
# Remove windows and macos from the JSON array
FILTERED_DIRS=$(echo "$ALL_CHANGED_DIRS" | jq -c '. - ["windows", "macos-node"]')
echo "filtered-dirs=$FILTERED_DIRS" >> $GITHUB_OUTPUT
- name: List all changed sample app dir_names (filtered)
# NOTE: this is referred to as a file by the action, despite technically being a chunk of the directory in use
env:
ALL_CHANGED_FILES: ${{ steps.filtered-changes.outputs.filtered-dirs }}
run: echo "${ALL_CHANGED_FILES}"
sample-app-testing:
name: Test sample-app
# Sample app testing requires a runner with support for nested virtualization
runs-on: ubuntu-latest-8-cores
permissions:
issues: write
contents: write
pull-requests: write
repository-projects: write
timeout-minutes: 30
needs: [check-for-changed-sample-apps]
strategy:
matrix:
sample-app: ${{ fromJSON(needs.check-for-changed-sample-apps.outputs.changed-sample-apps) }}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
persist-credentials: false
- name: Check sample-app supports CI execution
id: check_ci_support
env:
SAMPLE_APP: ${{ matrix.sample-app }}
run: |
export "CI_BYPASS=$(./ops/scripts/check_sample_app_ci_bypass.sh ${SAMPLE_APP})"
echo "CI_BYPASS=$CI_BYPASS" >> $GITHUB_OUTPUT
export "SUPPORTS_CI=$(./ops/scripts/check_sample_app_ci_compatible.sh ${SAMPLE_APP})"
echo "SUPPORTS_CI=$SUPPORTS_CI" >> $GITHUB_OUTPUT
echo $SUPPORTS_CI
- name: Warn user - sample-app incorrectly configured for CI
if: steps.check_ci_support.outputs.SUPPORTS_CI == 'false' && steps.check_ci_support.outputs.CI_BYPASS == 'false'
run: |
echo "[FAIL] The ${SAMPLE_APP} sample-app is not CI compatible and does not have a CI bypass file"
exit 1
# Note: @Dasomeone - 22nd July 2025 - Disabled for now to unblock PR
# Script fails to read the ${SAMPLE_APP} var despite clearly being defined (and working in other steps)
# - name: Warn user - CI bypass enabled
# if: steps.check_ci_support.outputs.CI_BYPASS == 'true'
# uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
# env:
# SAMPLE_APP: ${{ matrix.sample-app }}
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# const msg = `[WARNING] The ${SAMPLE_APP} sample-app has a .CI_BYPASS file and will **not** be tested in CI/CD.
#
# Please ensure it has been manually validated, and inform reviewers of such by ticking the below task and optionally informing users of the details.
# - [ ] Manual testing of ${SAMPLE_APP} sample-app has been completed`
#
# github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: msg
# })
- name: Install Multipass
if: steps.check_ci_support.outputs.SUPPORTS_CI == 'true' && steps.check_ci_support.outputs.CI_BYPASS == 'false'
run: sudo snap install multipass && sudo snap set system experimental.parallel-instances=true && sudo snap install multipass_socket
- name: Configure Multipass
if: steps.check_ci_support.outputs.SUPPORTS_CI == 'true' && steps.check_ci_support.outputs.CI_BYPASS == 'false'
run: sudo chmod a+w /var/snap/multipass/common/multipass_socket
- name: Checkout repo
if: steps.check_ci_support.outputs.SUPPORTS_CI == 'true' && steps.check_ci_support.outputs.CI_BYPASS == 'false'
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
persist-credentials: false
- name: Setup config & databases
if: steps.check_ci_support.outputs.SUPPORTS_CI == 'true' && steps.check_ci_support.outputs.CI_BYPASS == 'false'
run: |
./ops/scripts/setup_dbs.sh dbs qa
export "DB_IP=$(./ops/scripts/multipass_get_ips.sh dbs)"
echo "LOKI=$DB_IP:3100" >> $GITHUB_ENV
echo "MIMIR=$DB_IP:9009" >> $GITHUB_ENV
source ./ops/.defaultconfig
echo "SAMPLE_APP_SETUP_TIME=$SAMPLE_APP_SETUP_TIME" >> $GITHUB_ENV
- name: Run ${{ matrix.sample-app }} sample-app
if: steps.check_ci_support.outputs.SUPPORTS_CI == 'true' && steps.check_ci_support.outputs.CI_BYPASS == 'false'
working-directory: ./sample-apps/${{ matrix.sample-app }}
run: |
make LOKI_INSTANCE=${{ env.LOKI }} PROMETHEUS_INSTANCE=${{ env.MIMIR }} run-ci
- name: Wait for sample-app to generate metrics
if: steps.check_ci_support.outputs.SUPPORTS_CI == 'true' && steps.check_ci_support.outputs.CI_BYPASS == 'false'
run: sleep ${{ env.SAMPLE_APP_SETUP_TIME }}
- name: Check Prom metrics in Mimir
if: steps.check_ci_support.outputs.SUPPORTS_CI == 'true' && steps.check_ci_support.outputs.CI_BYPASS == 'false'
env:
SAMPLE_APP: ${{ matrix.sample-app }}
run: |
./ops/scripts/test_sample_app_metrics.sh ${SAMPLE_APP} $MIMIR
# test get link to this particular stage
echo "CHECK_METRICS_STEP_LINKL=https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks/${{ github.run_id }}"