-
Notifications
You must be signed in to change notification settings - Fork 1
162 lines (131 loc) · 5.39 KB
/
e2e.yml
File metadata and controls
162 lines (131 loc) · 5.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
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Functions Python App E2E Tests
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Serialize E2E tests to prevent deployment and UI collisions
concurrency:
group: e2e-tests-${{ github.repository }}
cancel-in-progress: false # Let running tests finish before starting new ones
permissions:
contents: read
jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 15
if: github.actor != 'dependabot[bot]'
env:
FOUNDRY_API_CLIENT_ID: ${{ secrets.FOUNDRY_API_CLIENT_ID }}
FOUNDRY_API_CLIENT_SECRET: ${{ secrets.FOUNDRY_API_CLIENT_SECRET }}
FOUNDRY_CID: ${{ secrets.FOUNDRY_CID }}
FOUNDRY_CLOUD_REGION: ${{ secrets.FOUNDRY_CLOUD_REGION }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@1ccc07ccd8b9519f44d3e5eaa1b41dd90310adf0 # master
- name: Install required tools
run: |
brew tap crowdstrike/foundry-cli
brew install crowdstrike/foundry-cli/foundry yq
- name: Create directory for Foundry CLI
run: mkdir -p ~/.config/foundry
- name: Prepare app manifest
run: |
# Remove IDs from manifest
yq -i 'del(.. | select(has("id")).id) | del(.. | select(has("app_id")).app_id)' manifest.yml
# Generate unique app name with length safety
REPO_NAME="${{ github.event.repository.name }}"
ACTOR="${{ github.actor }}"
SHORT_ACTOR="${ACTOR/dependabot\[bot\]/deps}"
UNIQUE_NAME="${REPO_NAME}-${SHORT_ACTOR}-$(date +"%m%d%H%M")"
# Truncate if too long by removing foundry- prefix
if [ ${#UNIQUE_NAME} -gt 50 ]; then
REPO_BASE="${REPO_NAME#foundry-}"
UNIQUE_NAME="${REPO_BASE}-${SHORT_ACTOR}-$(date +"%m%d%H%M")"
fi
# Export for yq and set the manifest name
export UNIQUE_NAME
yq -i '.name = env(UNIQUE_NAME)' manifest.yml
# Set app name as environment variable
APP_NAME=$(yq '.name' manifest.yml)
echo "APP_NAME=$APP_NAME" >> $GITHUB_ENV
echo "Prepared manifest with app name: $APP_NAME"
- name: Deploy app to Falcon
run: |
foundry apps deploy --change-type=major --change-log="e2e deploy"
echo "App deployment initiated"
- name: Wait for deployment and release app
run: |
echo "Waiting for deployment to complete..."
timeout=300 # 5 minute timeout
elapsed=0
while [ $elapsed -lt $timeout ]; do
if foundry apps list-deployments | grep -i "successful"; then
echo "Deployment successful, releasing app..."
foundry apps release --change-type=major --notes="e2e release"
echo "App released successfully"
# Brief wait for release to complete - E2E tests handle app discovery with retries
echo "Allowing brief time for release to complete..."
sleep 15
# Verify deployment status and get app details
echo "Verifying final deployment status..."
foundry apps list-deployments
echo "Final deployed app name: $APP_NAME"
exit 0
fi
if foundry apps list-deployments | grep -i "failed"; then
echo "Deployment failed"
exit 1
fi
sleep 5
elapsed=$((elapsed + 5))
done
echo "Deployment timeout after ${timeout} seconds"
exit 1
# Parallelize Node setup while deployment happens
- name: Install Node LTS
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: 22
cache: 'npm'
cache-dependency-path: e2e/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: e2e
- name: Install Playwright browsers
run: npx playwright install chromium --with-deps
working-directory: e2e
- name: Make envfile
uses: SpicyPizza/create-envfile@6da099c0b655bd3abd8273c4e2fe7c59e63fa88a # v2
with:
envkey_FALCON_USERNAME: ${{ secrets.FALCON_USERNAME }}
envkey_FALCON_PASSWORD: ${{ secrets.FALCON_PASSWORD }}
envkey_FALCON_AUTH_SECRET: ${{ secrets.FALCON_AUTH_SECRET }}
envkey_APP_NAME: $APP_NAME
directory: e2e
- name: Run Playwright tests
run: npx dotenvx run --quiet -- npx playwright test
working-directory: e2e
env:
CI: true
- name: Upload Playwright report
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: ${{ !cancelled() }}
with:
name: playwright-report-${{ env.APP_NAME }}
path: e2e/playwright-report/
retention-days: 7
- name: Upload test results and screenshots
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: ${{ !cancelled() }}
with:
name: playwright-test-results-${{ env.APP_NAME }}
path: e2e/test-results/
retention-days: 7
- name: Delete app from Falcon
if: always()
run: |
echo "Deleting app: $APP_NAME"
foundry apps delete -f || echo "App deletion failed, may already be deleted"