-
Notifications
You must be signed in to change notification settings - Fork 723
173 lines (149 loc) · 5.42 KB
/
test-c3.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
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
163
164
165
166
167
168
169
170
171
172
173
name: C3 Tests
on:
pull_request:
paths:
- packages/create-cloudflare/**
env:
node-version: 18.17.1
bun-version: 1.0.3
jobs:
check:
name: "Checks"
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
- name: Check Types
run: pnpm run --filter create-cloudflare check:type
- name: Lint
run: pnpm run --filter create-cloudflare check:lint
- name: Unit Tests
run: pnpm run --filter create-cloudflare test:unit
cleanup:
name: "Cleanup Test Projects"
if: ${{ github.repository_owner == 'cloudflare' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
- name: Cleanup E2E test projects
run: pnpm run --filter create-cloudflare test:e2e:cleanup
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.C3_TEST_CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.C3_TEST_CLOUDFLARE_ACCOUNT_ID }}
e2e:
needs: cleanup
name: ${{ format('E2E ({0}) {1}', matrix.pm, matrix.quarantine == true && '[quarantine]' || '') }}
continue-on-error: ${{ matrix.quarantine }}
if: |
github.event.pull_request.user.login != 'dependabot[bot]'
strategy:
matrix:
os: [ubuntu-latest]
pm: [npm, pnpm, bun]
quarantine: [true, false]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
- name: Install Bun ${{ env.bun-version }}
uses: oven-sh/setup-bun@v1
with:
bun-version: ${{ env.bun-version }}
# Needed because gatsby requires git
- name: Configure Git
run: |
git config --global user.email wrangler@cloudflare.com
git config --global user.name 'Wrangler automated PR updater'
- name: E2E Tests
run: pnpm run --filter create-cloudflare test:e2e:${{matrix.pm}}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.C3_TEST_CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.C3_TEST_CLOUDFLARE_ACCOUNT_ID }}
E2E_QUARANTINE: ${{ matrix.quarantine }}
get-dependabot-bumped-framework:
name: "Get bumped framework (dependabot-only)"
runs-on: ubuntu-latest
outputs:
bumped-framework-cli: ${{ steps.detect.outputs.result }}
if: |
github.event.pull_request.user.login == 'dependabot[bot]'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
ref: ${{ github.head_ref }}
- name: Get PR description as string
id: get-pr-description
run: |
str=$(sed 's/`/\`/g' <<EOF
${{ github.event.pull_request.body }}
EOF
)
echo 'result<<EOF' >> $GITHUB_OUTPUT
echo $str >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: detect-bumped-framework
id: detect
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const json = require('./packages/create-cloudflare/src/frameworks/package.json')
const frameworkCliPackages = Object.values(json.frameworkCliMap);
const body = `${{ steps.get-pr-description.outputs.result }}`;
const semverRegexStr = '\\d+\\.\\d+\\.\\d+';
const frameworkCliRegex = new RegExp(
`(?:^|\\s+)Bumps\\s+\\[(${frameworkCliPackages.join(
'|'
)})\\]\\(.*?\\)\\s+from\\s+${semverRegexStr}\\s+to\\s+${semverRegexStr}`
);
const bumpedFrameworkCli = body.match(frameworkCliRegex)?.[1] ?? '';
return bumpedFrameworkCli;
# For dependabot versioning PRs we only want to run the e2es for the specifically bumped
# framework (this is both for optimization and in order to reduce unnecessary flakiness)
e2e-only-dependabot-bumped-framework:
needs: [cleanup, get-dependabot-bumped-framework]
name: ${{ format('Dependabot E2E ({0}) {1}', matrix.pm, matrix.quarantine == true && '[quarantine]' || '') }}
continue-on-error: ${{ matrix.quarantine }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
pm: [npm, pnpm, bun]
quarantine: [true, false]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
- name: Install Bun ${{ env.bun-version }}
uses: oven-sh/setup-bun@v1
with:
bun-version: ${{ env.bun-version }}
- name: E2E Tests
run: pnpm run --filter create-cloudflare test:e2e:${{matrix.pm}}
env:
FRAMEWORK_CLI_TO_TEST: ${{ needs.get-dependabot-bumped-framework.outputs.bumped-framework-cli }}
CLOUDFLARE_API_TOKEN: ${{ secrets.C3_TEST_CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.C3_TEST_CLOUDFLARE_ACCOUNT_ID }}
E2E_QUARANTINE: ${{ matrix.quarantine }}