Skip to content

Commit de95298

Browse files
committed
feat: run new test concept everywhere
1 parent 1ae06cb commit de95298

File tree

3 files changed

+110
-264
lines changed

3 files changed

+110
-264
lines changed

.github/workflows/test-integration.yml

Lines changed: 25 additions & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -17,271 +17,64 @@ defaults:
1717
shell: bash -leo pipefail {0}
1818

1919
jobs:
20-
setup-repositories:
21-
name: Set up Integration Tests
20+
integration-tests:
21+
name: Run Integration Tests
2222
# if triggered by pull_request, only run on non-fork PRs (secrets access needed)
2323
# Nevertheless, this check is always run in the merge queue.
2424
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
2525
runs-on: ubuntu-latest
26-
outputs:
27-
scenario_ids: ${{ steps.setup_repositories.outputs.scenario_ids }}
2826
steps:
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
29+
2930
- name: Checkout
3031
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3132
with:
3233
path: cf-scripts
33-
34-
- name: Set up Docker Buildx
35-
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
34+
submodules: 'true'
3635

3736
- name: Build Docker Image
38-
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
37+
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
3938
with:
4039
context: cf-scripts
4140
push: false
4241
load: true
4342
tags: conda-forge-tick:test
4443
cache-from: type=gha
4544
cache-to: type=gha,mode=max
46-
outputs: type=docker,dest=/tmp/image.tar
4745

48-
- name: Upload Docker Image
49-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
46+
- name: Setup micromamba
47+
uses: mamba-org/setup-micromamba@0dea6379afdaffa5d528b3d1dabc45da37f443fc # v2.0.4
5048
with:
51-
name: conda-forge-tick
52-
path: /tmp/image.tar
53-
54-
- name: setup-micromamba
55-
uses: mamba-org/setup-micromamba@4b9113af4fba0e9e1124b252dd6497a419e7396d # v1.11.0
56-
with:
57-
environment-file: cf-scripts/conda-lock.yml
49+
environment-file: conda-lock.yml
5850
environment-name: cf-scripts
59-
condarc-file: cf-scripts/autotick-bot/condarc
51+
condarc-file: autotick-bot/condarc
6052

6153
- name: Run pip install
6254
working-directory: cf-scripts
6355
run: |
6456
pip install --no-deps --no-build-isolation -e .
6557
66-
- name: Set up Integration Test Repositories
67-
id: setup_repositories
58+
- name: Run mitmproxy certificate setup wizard
6859
working-directory: cf-scripts
69-
# note: this writes `scenario_ids` to GITHUB_OUTPUT
70-
run: python -m tests_integration.setup_repositories
71-
env:
72-
TEST_SETUP_TOKEN: ${{ secrets.GH_TOKEN_STAGING_BOT_USER }}
73-
74-
run-test-scenario:
75-
name: Run Scenarios
76-
# if triggered by pull_request, only run on non-fork PRs (secrets access needed)
77-
# Nevertheless, this check is always run in the merge queue.
78-
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
79-
runs-on: ubuntu-latest
80-
needs: setup-repositories
81-
strategy:
82-
matrix:
83-
scenario_id: ${{ fromJson(needs.setup-repositories.outputs.scenario_ids) }}
84-
max-parallel: 1
85-
fail-fast: false
86-
steps:
87-
- name: Checkout
88-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
89-
with:
90-
path: cf-scripts
91-
submodules: 'true'
92-
93-
- name: Download Docker Image
94-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
95-
with:
96-
name: conda-forge-tick
97-
path: /tmp
98-
99-
- name: setup-micromamba
100-
uses: mamba-org/setup-micromamba@4b9113af4fba0e9e1124b252dd6497a419e7396d # v1.11.0
101-
with:
102-
environment-file: cf-scripts/conda-lock.yml
103-
environment-name: cf-scripts
104-
condarc-file: cf-scripts/autotick-bot/condarc
105-
106-
- name: Install Bot Code (no graph clone)
107-
# this is the first time, so we clean disk space, but don't clone the graph
108-
run: source cf-scripts/autotick-bot/install_bot_code.sh --no-pull-container --no-clone-graph
109-
110-
- name: Load Docker Image
111-
run: |
112-
docker load --input /tmp/image.tar
113-
docker image ls -a
114-
115-
- name: Prepare Scenario
116-
working-directory: cf-scripts
117-
run: python -m tests_integration.step_prepare # this creates the cf-graph repository
118-
env:
119-
SCENARIO_ID: ${{ matrix.scenario_id }}
120-
TEST_SETUP_TOKEN: ${{ secrets.GH_TOKEN_STAGING_BOT_USER }}
121-
122-
- name: Install Bot Code
12360
run: |
124-
source cf-scripts/autotick-bot/install_bot_code.sh --no-pull-container --no-clean-disk-space
125-
126-
- name: Start HTTP Proxy
127-
working-directory: cf-scripts
128-
run: |
129-
./tests_integration/mock_proxy_start.sh &
130-
sleep 10
131-
# Install CA Certificate
132-
sudo wget -e use_proxy=yes -e http_proxy=127.0.0.1:8080 -O /usr/local/share/ca-certificates/mitmproxy.crt \
133-
http://mitm.it/cert/pem
61+
# place a script in the mitmproxy directory that will be run by the setup wizard
62+
# to trust the mitmproxy certificate
63+
cat <<EOF "${MITMPROXY_WIZARD_HEADLESS_TRUST_SCRIPT}"
64+
#!/usr/bin/env bash
65+
set -euo pipefail
66+
sudo cp "$1" /usr/local/share/ca-certificates/mitmproxy.crt
13467
sudo update-ca-certificates
135-
env:
136-
SCENARIO_ID: ${{ matrix.scenario_id }}
137-
PYTHONPATH: ${{ github.workspace }}/cf-scripts
68+
EOF
13869
139-
- name: "[Test] Gather all Feedstocks"
140-
working-directory: cf-graph
141-
run: |
142-
# don't use proxy for git CLI operations (applies to all further steps)
143-
git config --global http."https://github.com".proxy ""
144-
conda-forge-tick --debug gather-all-feedstocks
145-
146-
- name: "[Test] Deploy to GitHub"
147-
working-directory: cf-graph
148-
run: conda-forge-tick --debug deploy-to-github
149-
150-
- name: Reinstall Bot Code
151-
run: |
152-
source cf-scripts/tests_integration/clear_runner.sh
153-
source cf-scripts/autotick-bot/install_bot_code.sh --no-clean-disk-space --no-pull-container
154-
155-
- name: "[Test] Make Graph (Nodes and Edges)"
156-
working-directory: cf-graph
157-
run: conda-forge-tick --debug make-graph --update-nodes-and-edges
158-
159-
- name: "[Test] Deploy to GitHub"
160-
working-directory: cf-graph
161-
run: conda-forge-tick --debug deploy-to-github
162-
163-
- name: Reinstall Bot Code
164-
run: |
165-
source cf-scripts/tests_integration/clear_runner.sh
166-
source cf-scripts/autotick-bot/install_bot_code.sh --no-clean-disk-space --no-pull-container
167-
168-
- name: "[Test] Make Graph (Node Attributes)"
169-
working-directory: cf-graph
170-
run: conda-forge-tick --debug make-graph
171-
env:
172-
CF_TICK_FRAC_MAKE_GRAPH: "1.0"
173-
174-
- name: "[Test] Deploy to GitHub"
175-
working-directory: cf-graph
176-
run: conda-forge-tick --debug deploy-to-github
177-
178-
- name: Reinstall Bot Code
179-
run: |
180-
source cf-scripts/tests_integration/clear_runner.sh
181-
source cf-scripts/autotick-bot/install_bot_code.sh --no-clean-disk-space --no-pull-container
182-
183-
- name: "[Test] update-upstream-versions"
184-
working-directory: cf-graph
185-
run: conda-forge-tick --debug update-upstream-versions
186-
env:
187-
http_proxy: http://127.0.0.1:8080
188-
https_proxy: http://127.0.0.1:8080
189-
SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt
190-
REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
191-
CF_FEEDSTOCK_OPS_CONTAINER_PROXY_MODE: true
192-
CF_FEEDSTOCK_OPS_PROXY_IN_CONTAINER: http://172.17.0.1:8080
193-
194-
- name: "[Test] Deploy to GitHub"
195-
working-directory: cf-graph
196-
run: conda-forge-tick --debug deploy-to-github
197-
198-
- name: Reinstall Bot Code
199-
run: |
200-
source cf-scripts/tests_integration/clear_runner.sh
201-
source cf-scripts/autotick-bot/install_bot_code.sh --no-clean-disk-space --no-pull-container
202-
203-
- name: "[Test] make-migrators (1/2)"
204-
working-directory: cf-graph
205-
run: conda-forge-tick --debug make-migrators
206-
env:
207-
http_proxy: http://127.0.0.1:8080
208-
https_proxy: http://127.0.0.1:8080
209-
SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt
210-
REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
211-
CF_FEEDSTOCK_OPS_CONTAINER_PROXY_MODE: true
212-
CF_FEEDSTOCK_OPS_PROXY_IN_CONTAINER: http://172.17.0.1:8080
213-
214-
- name: "[Test] Deploy to GitHub"
215-
working-directory: cf-graph
216-
run: conda-forge-tick --debug deploy-to-github
217-
218-
- name: Reinstall Bot Code
219-
run: |
220-
source cf-scripts/tests_integration/clear_runner.sh
221-
source cf-scripts/autotick-bot/install_bot_code.sh --no-clean-disk-space --no-pull-container
222-
223-
- name: "[Test] auto-tick (1/2)"
224-
working-directory: cf-graph
225-
run: conda-forge-tick --debug auto-tick
226-
env:
227-
http_proxy: http://127.0.0.1:8080
228-
https_proxy: http://127.0.0.1:8080
229-
SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt
230-
REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
231-
CF_FEEDSTOCK_OPS_CONTAINER_PROXY_MODE: true
232-
CF_FEEDSTOCK_OPS_PROXY_IN_CONTAINER: http://172.17.0.1:8080
233-
234-
- name: "[Test] Deploy to GitHub"
235-
working-directory: cf-graph
236-
run: conda-forge-tick --debug deploy-to-github
237-
238-
- name: Reinstall Bot Code
239-
run: |
240-
source cf-scripts/tests_integration/clear_runner.sh
241-
source cf-scripts/autotick-bot/install_bot_code.sh --no-clean-disk-space --no-pull-container
242-
243-
- name: "[Test] make-migrators (2/2)"
244-
working-directory: cf-graph
245-
run: conda-forge-tick --debug make-migrators
70+
./tests_integration/mitmproxy_setup_wizard.sh
24671
env:
247-
http_proxy: http://127.0.0.1:8080
248-
https_proxy: http://127.0.0.1:8080
249-
SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt
250-
REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
251-
CF_FEEDSTOCK_OPS_CONTAINER_PROXY_MODE: true
252-
CF_FEEDSTOCK_OPS_PROXY_IN_CONTAINER: http://172.17.0.1:8080
253-
254-
- name: "[Test] Deploy to GitHub"
255-
working-directory: cf-graph
256-
run: conda-forge-tick --debug deploy-to-github
257-
258-
- name: Reinstall Bot Code
259-
run: |
260-
source cf-scripts/tests_integration/clear_runner.sh
261-
source cf-scripts/autotick-bot/install_bot_code.sh --no-clean-disk-space --no-pull-container
72+
MITMPROXY_WIZARD_HEADLESS: true
73+
MITMPROXY_WIZARD_HEADLESS_TRUST_SCRIPT: ./tests_integration/.mitmproxy/mitmproxy_trust_script.sh
26274

263-
- name: "[Test] auto-tick (2/2)"
264-
working-directory: cf-graph
265-
run: conda-forge-tick --debug auto-tick
266-
env:
267-
http_proxy: http://127.0.0.1:8080
268-
https_proxy: http://127.0.0.1:8080
269-
SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt
270-
REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
271-
CF_FEEDSTOCK_OPS_CONTAINER_PROXY_MODE: true
272-
CF_FEEDSTOCK_OPS_PROXY_IN_CONTAINER: http://172.17.0.1:8080
273-
274-
- name: "[Test] Deploy to GitHub"
275-
working-directory: cf-graph
276-
run: conda-forge-tick --debug deploy-to-github
277-
278-
- name: Validate Scenario
75+
- name: Run Integration Tests with pytest
27976
working-directory: cf-scripts
280-
run: python -m tests_integration.step_validate
77+
run: pytest -s -v tests_integration
28178
env:
282-
SCENARIO_ID: ${{ matrix.scenario_id }}
79+
BOT_TOKEN: ${{ secrets.GH_TOKEN_STAGING_BOT_USER }}
28380
TEST_SETUP_TOKEN: ${{ secrets.GH_TOKEN_STAGING_BOT_USER }}
284-
285-
- name: Print Proxy Logs
286-
if: always()
287-
run: cat /tmp/mitmproxy.log

tests_integration/mitmproxy_setup_wizard.sh

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env bash
2+
13
set -euo pipefail
24

35
echo "=== mitmproxy certificates setup wizard ==="
4-
echo "Use this shell script to setup the mitmproxy certificates for the integration tests on your local machine."
6+
echo "Use this shell script to setup the mitmproxy certificates for the integration tests on your machine."
57

68
# we could also add openssl to the conda environment, but this should be available on most systems
79
if ! command -v openssl &> /dev/null; then
@@ -11,26 +13,47 @@ fi
1113

1214
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1315
mitmproxy_dir="${script_dir}/.mitmproxy"
14-
1516
# the mitmproxy_dir should already exist
1617
cd "${mitmproxy_dir}"
1718

18-
echo "Press enter to generate the mitmproxy certificates."
19-
read -r
19+
# Headless Mode is used in GitHub Actions only
20+
headless_mode="${MITMPROXY_WIZARD_HEADLESS:-false}"
21+
22+
if [ "${headless_mode}" = "true" ]; then
23+
echo "Running in headless mode."
24+
echo "The mitmproxy certificates will be generated in the directory: ${mitmproxy_dir}"
25+
else
26+
echo "The mitmproxy certificates will be generated in the directory: ${mitmproxy_dir}"
27+
echo "Press enter to continue or Ctrl+C to cancel."
28+
read -r
29+
fi
2030

2131
openssl genrsa -out mitmproxy-ca.key 4096
2232
openssl req -x509 -new -nodes -key mitmproxy-ca.key -sha256 -days 365 -out mitmproxy-ca.crt -addext keyUsage=critical,keyCertSign -subj "/C=US/ST=cf-scripts/L=cf-scripts/O=cf-scripts/OU=cf-scripts/CN=cf-scripts"
2333
cat mitmproxy-ca.key mitmproxy-ca.crt > mitmproxy-ca.pem
2434

35+
# path to a script that will be executed after the certificates have been generated
36+
# the script should add the mitmproxy-ca.pem certificate to the system's trust store
37+
# the first argument is the path to the mitmproxy-ca.pem certificate
38+
headless_mode_trust_script="${MITMPROXY_WIZARD_HEADLESS_TRUST_SCRIPT})"
39+
2540
echo "The mitmproxy certificates have been generated successfully."
2641
echo "The root certificate will be valid for 365 days."
27-
echo "You now need to trust the mitmproxy-ca.pem certificate in your system's trust store."
28-
echo "The exact process depends on your operating system."
29-
echo "On MacOS, drag and drop the mitmproxy-ca.pem file into the Keychain Access app while having the 'Login' keychain selected."
30-
echo "Then, double-click the certificate in the keychain and set ‘Always Trust‘ in the ‘Trust‘ section."
31-
echo "The certificate is located at: ${mitmproxy_dir}/mitmproxy-ca.pem"
32-
echo "After you're done, press enter to continue."
33-
read -r
42+
43+
mitmproxy_ca_pem_file="${mitmproxy_dir}/mitmproxy-ca.pem"
44+
45+
if [ "${headless_mode}" = "true" ]; then
46+
echo "Executing the headless mode trust script..."
47+
bash "${headless_mode_trust_script}" "${mitmproxy_ca_pem_file}"
48+
else
49+
echo "You now need to trust the mitmproxy-ca.pem certificate in your system's trust store."
50+
echo "The exact process depends on your operating system."
51+
echo "On MacOS, drag and drop the mitmproxy-ca.pem file into the Keychain Access app while having the 'Login' keychain selected."
52+
echo "Then, double-click the certificate in the keychain and set ‘Always Trust‘ in the ‘Trust‘ section."
53+
echo "The certificate is located at: ${mitmproxy_ca_pem_file}"
54+
echo "After you're done, press enter to continue."
55+
read -r
56+
fi
3457

3558
echo "Generating the certificate bundle mitmproxy-cert-bundle.pem to pass to Python..."
3659
cp "$(python -m certifi)" mitmproxy-cert-bundle.pem

0 commit comments

Comments
 (0)