Skip to content

Commit e7f0694

Browse files
committed
Merge branch 'main' into feat/add-creator-field-to-master-api-keys
# Conflicts: # api/tests/integration/api_keys/test_viewset.py # frontend/web/components/AdminAPIKeys.js
2 parents 6f2f9ec + 71968be commit e7f0694

File tree

580 files changed

+43523
-25115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

580 files changed

+43523
-25115
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Depot CI Migration
2+
# Source: .github/workflows/api-pull-request.yml
3+
#
4+
# No changes were necessary.
5+
6+
name: API Pull Request
7+
permissions:
8+
contents: read # For actions/checkout
9+
id-token: write # For Codecov OIDC
10+
on:
11+
pull_request:
12+
paths:
13+
- api/**
14+
- docker/api/**
15+
- .depot/**
16+
- .release-please-manifest.json
17+
types: [opened, synchronize, reopened, ready_for_review]
18+
push:
19+
paths:
20+
- api/**
21+
- docker/api/**
22+
- .depot/**
23+
- .release-please-manifest.json
24+
branches:
25+
- main
26+
defaults:
27+
run:
28+
working-directory: api
29+
env:
30+
DOTENV_OVERRIDE_FILE: .env-ci
31+
jobs:
32+
test:
33+
runs-on: depot-ubuntu-latest-16
34+
name: API Unit Tests
35+
strategy:
36+
max-parallel: 3
37+
matrix:
38+
python-version: ["3.11", "3.12", "3.13"]
39+
steps:
40+
- name: Cloning repo
41+
uses: actions/checkout@v5
42+
- name: Install Poetry
43+
run: make install-poetry
44+
- uses: actions/setup-python@v5
45+
with:
46+
python-version: ${{ matrix.python-version }}
47+
cache: poetry
48+
- name: Install Dependencies
49+
run: make install-packages
50+
- name: Check for missing migrations
51+
env:
52+
opts: --no-input --dry-run --check
53+
run: make django-make-migrations
54+
- uses: liskin/gh-problem-matcher-wrap@v2
55+
with:
56+
action: add
57+
linters: mypy
58+
- name: Check for new typing errors
59+
run: make typecheck
60+
- uses: liskin/gh-problem-matcher-wrap@v2
61+
with:
62+
action: remove
63+
linters: mypy
64+
- name: Check autogenerated documentation
65+
uses: nickcharlton/diff-check@v1.0.0
66+
with:
67+
command: make -C api generate-docs
68+
- name: Run Tests
69+
run: make test
70+
- name: Upload Coverage
71+
uses: codecov/codecov-action@v5
72+
env:
73+
PYTHON: ${{ matrix.python-version }}
74+
with:
75+
env_vars: PYTHON
76+
use_oidc: true

.github/actions/e2e-tests/action.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,26 @@ runs:
2626
node-version-file: frontend/.nvmrc
2727
cache-dependency-path: frontend/package-lock.json
2828

29+
- name: Cache Playwright browsers
30+
uses: actions/cache@v4
31+
with:
32+
path: ~/.cache/ms-playwright
33+
key: ${{ runner.os }}-playwright-${{ hashFiles('frontend/package-lock.json') }}
34+
restore-keys: |
35+
${{ runner.os }}-playwright-
36+
2937
- name: NPM Install
3038
working-directory: frontend
3139
run: |
3240
npm ci
3341
shell: bash
3442

35-
- name: Test with Chromedriver
43+
- name: Install Playwright browsers
44+
working-directory: frontend
45+
run: npm run test:install
46+
shell: bash
47+
48+
- name: Run E2E tests
3649
uses: nick-fields/retry@v3
3750
with:
3851
shell: bash

.github/workflows/.reusable-docker-build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,11 @@ jobs:
148148

149149
- name: Scan ${{ steps.image-tag.outputs.image-tag }} image
150150
id: trivy
151-
uses: Flagsmith/actions/trivy-scan-image@v0.3.0
151+
uses: Flagsmith/actions/trivy-scan-image@v0.4.1
152152
if: inputs.scan
153153
with:
154154
image-tag: ${{ steps.image-tag.outputs.image-tag }}
155+
artifact-name: ${{ inputs.image-name }}-trivy-results
155156
category: ${{ inputs.image-name }}
156157
# `query` value contained path:{image_name} before but not all Trivy findings
157158
# conform to that. There's no category filter at the moment; for the time being,

.github/workflows/.reusable-docker-e2e-tests.yml

Lines changed: 92 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
required: true
1515
args:
1616
type: string
17-
description: Additional arguments to testcafe
17+
description: Additional arguments to playwright
1818
required: false
1919
default: ''
2020
concurrency:
@@ -44,6 +44,7 @@ jobs:
4444
contents: read
4545
packages: read
4646
id-token: write
47+
pull-requests: write
4748

4849
env:
4950
GCR_TOKEN: ${{ secrets.GCR_TOKEN }}
@@ -52,6 +53,17 @@ jobs:
5253
- name: Cloning repo
5354
uses: actions/checkout@v5
5455

56+
- name: Determine test type
57+
id: test-type
58+
run: |
59+
if [[ '${{ inputs.args }}' == *"@enterprise"* ]]; then
60+
echo "type=private-cloud" >> $GITHUB_OUTPUT
61+
echo "label=private-cloud" >> $GITHUB_OUTPUT
62+
else
63+
echo "type=oss" >> $GITHUB_OUTPUT
64+
echo "label=oss" >> $GITHUB_OUTPUT
65+
fi
66+
5567
- name: Login to Github Container Registry
5668
if: ${{ env.GCR_TOKEN }}
5769
uses: docker/login-action@v3
@@ -67,22 +79,89 @@ jobs:
6779
run: depot pull-token | docker login -u x-token --password-stdin registry.depot.dev
6880

6981
- name: Run tests on dockerised frontend
70-
uses: nick-fields/retry@v3
71-
with:
72-
shell: bash
73-
command: |
74-
cd frontend
75-
make test
76-
max_attempts: 2
77-
retry_on: error
78-
timeout_minutes: 20
79-
on_retry_command: |
80-
cd frontend
81-
docker compose down --remove-orphans || true
82+
working-directory: frontend
83+
run: make test
8284
env:
8385
opts: ${{ inputs.args }}
8486
API_IMAGE: ${{ inputs.api-image }}
8587
E2E_IMAGE: ${{ inputs.e2e-image }}
8688
E2E_CONCURRENCY: ${{ inputs.concurrency }}
89+
E2E_RETRIES: 2
8790
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
8891
GITHUB_ACTION_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
92+
timeout-minutes: 20
93+
94+
- name: Cleanup E2E services
95+
if: always()
96+
working-directory: frontend
97+
run: docker compose down --remove-orphans || true
98+
99+
- name: Copy results.json to HTML report
100+
if: always()
101+
run: |
102+
cp frontend/e2e/test-results/results.json frontend/e2e/playwright-report/ || true
103+
104+
- name: Upload HTML report
105+
if: failure()
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: playwright-html-report-${{ steps.test-type.outputs.type }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ strategy.job-index }}
109+
path: frontend/e2e/playwright-report/
110+
retention-days: 30
111+
if-no-files-found: warn
112+
113+
- name: Set artifact URL
114+
if: failure() && github.event_name == 'pull_request'
115+
id: artifact-url
116+
run: |
117+
echo "url=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts" >> $GITHUB_OUTPUT
118+
119+
- name: Send Slack notification and upload report
120+
if: failure()
121+
working-directory: frontend
122+
run: |
123+
cd e2e
124+
zip -r playwright-report.zip playwright-report/ || echo "Failed to zip report"
125+
cd ..
126+
npm install --no-save @slack/web-api
127+
npx -y tsx e2e/slack-e2e-reporter.ts
128+
env:
129+
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
130+
GITHUB_ACTION_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
131+
GITHUB_REF_NAME: ${{ github.ref_name }}
132+
GITHUB_HEAD_REF: ${{ github.head_ref }}
133+
TEST_TYPE: ${{ steps.test-type.outputs.label }}
134+
PR_NUMBER: ${{ github.event.pull_request.number }}
135+
PR_TITLE: ${{ github.event.pull_request.title }}
136+
PR_URL: ${{ github.event.pull_request.html_url }}
137+
138+
- name: Generate test report summary (success)
139+
id: report-summary-success
140+
if: success() && github.event_name == 'pull_request'
141+
uses: daun/playwright-report-summary@v3
142+
with:
143+
report-file: frontend/e2e/playwright-report/results.json
144+
comment-title: 'Playwright Test Results (${{ steps.test-type.outputs.label }} - ${{ inputs.runs-on }})'
145+
create-comment: false
146+
custom-info: |
147+
**🔄 Run:** [#${{ github.run_number }} (attempt ${{ github.run_attempt }})](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
148+
149+
- name: Generate test report summary (failure)
150+
id: report-summary-failure
151+
if: failure() && github.event_name == 'pull_request'
152+
uses: daun/playwright-report-summary@v3
153+
with:
154+
report-file: frontend/e2e/playwright-report/results.json
155+
comment-title: 'Playwright Test Results (${{ steps.test-type.outputs.label }} - ${{ inputs.runs-on }})'
156+
create-comment: false
157+
custom-info: |
158+
**📦 Artifacts:** [View test results and HTML report](${{ steps.artifact-url.outputs.url }})
159+
**🔄 Run:** [#${{ github.run_number }} (attempt ${{ github.run_attempt }})](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
160+
161+
- name: Comment PR with test results
162+
if: always() && github.event_name == 'pull_request' && (steps.report-summary-success.outputs.summary || steps.report-summary-failure.outputs.summary)
163+
uses: marocchino/sticky-pull-request-comment@v2
164+
with:
165+
header: playwright-e2e-results
166+
append: true
167+
message: ${{ steps.report-summary-success.outputs.summary || steps.report-summary-failure.outputs.summary }}

.github/workflows/frontend-test-staging.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,6 @@ jobs:
1515
- name: Cloning repo
1616
uses: actions/checkout@v5
1717

18-
# Temporarily install Firefox 143.0 to avoid test failures as superior versions cause frontend e2e tests to hang
19-
# To be removed once upstream issue correctly resolved
20-
- name: Install Firefox 143.0
21-
run: |
22-
sudo apt-get remove -y firefox || true
23-
sudo rm -rf /usr/bin/firefox /usr/lib/firefox*
24-
25-
ARCH=$(uname -m)
26-
wget -O /tmp/firefox.tar.xz "https://ftp.mozilla.org/pub/firefox/releases/143.0/linux-${ARCH}/en-US/firefox-143.0.tar.xz"
27-
sudo tar -xJf /tmp/firefox.tar.xz -C /opt
28-
sudo ln -s /opt/firefox/firefox /usr/local/bin/firefox
29-
rm /tmp/firefox.tar.xz
30-
31-
firefox --version
32-
33-
3418
- name: Run E2E tests against staging
3519
uses: ./.github/actions/e2e-tests
3620
with:

.github/workflows/platform-docker-build-e2e-image.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/platform-docker-build-test-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ jobs:
9494
runs-on: [depot-ubuntu-latest-16, depot-ubuntu-latest-arm-16]
9595
args:
9696
- api-image: ${{ needs.docker-build-api.outputs.image }}
97-
args: --meta-filter category=oss
97+
args: --grep @oss
9898
- api-image: ${{ needs.docker-build-private-cloud-api.outputs.image }}
99-
args: --meta-filter category=oss,category=enterprise
99+
args: --grep "@oss|@enterprise"
100100

101101
# Publish to dockerhub
102102

.github/workflows/platform-docker-trivy-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101

102102
- name: Scan ${{ matrix.image-name }}:main image
103103
id: trivy
104-
uses: Flagsmith/actions/trivy-scan-image@v0.4.0
104+
uses: Flagsmith/actions/trivy-scan-image@v0.4.1
105105
with:
106106
image-tag: ${{ env.REGISTRY_URL }}/flagsmith/${{ matrix.image-name }}:main
107107
category: ${{ matrix.image-name }}

.github/workflows/platform-pull-request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
runs-on: ${{ matrix.runs-on }}
151151
e2e-image: ${{ needs.docker-build-e2e.outputs.image }}
152152
api-image: ${{ needs.docker-build-api.outputs.image }}
153-
args: --meta-filter category=oss
153+
args: --grep @oss
154154
secrets:
155155
GCR_TOKEN: ${{ needs.permissions-check.outputs.can-write == 'true' && secrets.GITHUB_TOKEN || '' }}
156156
SLACK_TOKEN: ${{ needs.permissions-check.outputs.can-write == 'true' && secrets.SLACK_TOKEN || '' }}
@@ -167,7 +167,7 @@ jobs:
167167
runs-on: ${{ matrix.runs-on }}
168168
e2e-image: ${{ needs.docker-build-e2e.outputs.image }}
169169
api-image: ${{ needs.docker-build-private-cloud.outputs.image }}
170-
args: --meta-filter category=oss,category=enterprise
170+
args: --grep "@oss|@enterprise"
171171
secrets:
172172
GCR_TOKEN: ${{ needs.permissions-check.outputs.can-write == 'true' && secrets.GITHUB_TOKEN || '' }}
173173
SLACK_TOKEN: ${{ needs.permissions-check.outputs.can-write == 'true' && secrets.SLACK_TOKEN || '' }}

.github/workflows/update-flagsmith-environment.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ jobs:
3333
run: poetry run python manage.py updateflagsmithenvironment
3434

3535
- name: Create Pull Request
36-
uses: peter-evans/create-pull-request@v5
36+
uses: peter-evans/create-pull-request@v8
3737
with:
3838
commit-message: Update API Flagsmith Defaults
39-
branch: chore/update-api-flagsmith-environment
4039
delete-branch: true
41-
title: 'chore: update Flagsmith environment document'
40+
title: 'chore: Update Flagsmith environment document'
4241
labels: api
42+
token: ${{ secrets.UPDATE_ENVIRONMENT_DOCUMENT_WORKFLOW_GH_PAT }}

0 commit comments

Comments
 (0)