Skip to content

Commit 708bd59

Browse files
authored
Merge pull request #1411 from zloirock/pages
2 parents 84c282a + 6f2a540 commit 708bd59

File tree

6 files changed

+126
-5
lines changed

6 files changed

+126
-5
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Build and Deploy pages to GitHub Pages
2+
on: [push, workflow_dispatch]
3+
4+
permissions:
5+
contents: read
6+
pages: write
7+
id-token: write
8+
9+
jobs:
10+
list-branches:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
branches: ${{ steps.set-branches.outputs.branches }}
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Get branch list and set output
20+
id: set-branches
21+
run: |
22+
BRANCHES=$(
23+
git branch -r |
24+
grep -Ev 'HEAD|v1|v2' |
25+
sed 's/^[ *]*//' |
26+
sed 's/^origin\///' |
27+
jq -R . |
28+
jq -cs
29+
)
30+
echo "branches=$BRANCHES" >> "$GITHUB_OUTPUT"
31+
32+
build-compat-pages:
33+
needs: list-branches
34+
runs-on: ubuntu-latest
35+
strategy:
36+
matrix:
37+
branch: ${{ fromJson(needs.list-branches.outputs.branches) }}
38+
name: Build for ${{ matrix.branch }}
39+
steps:
40+
- uses: actions/checkout@v4
41+
with:
42+
ref: ${{ matrix.branch }}
43+
- name: Build cache key
44+
id: cache-key
45+
run: |
46+
HASH=$(git rev-parse --short HEAD)
47+
echo "CACHE_KEY=${{ matrix.branch }}-$HASH" >> "$GITHUB_ENV"
48+
- name: Restore cached artifacts
49+
id: artifacts-restore
50+
uses: actions/cache/restore@v4
51+
with:
52+
path: ${{ matrix.branch }}
53+
key: ${{ env.CACHE_KEY }}
54+
- uses: actions/setup-node@v4
55+
if: steps.artifacts-restore.outputs.cache-hit != 'true'
56+
with:
57+
node-version: 23
58+
cache: npm
59+
- name: Build
60+
if: steps.artifacts-restore.outputs.cache-hit != 'true'
61+
run: |
62+
npm ci
63+
npm run build-compat
64+
npm run bundle
65+
- name: Prepare build artifacts
66+
if: steps.artifacts-restore.outputs.cache-hit != 'true'
67+
run: |
68+
mkdir -p ${{ matrix.branch }}/compat
69+
cp tests/compat/index.html tests/compat/compat-data.js tests/compat/tests.js tests/compat/browsers-runner.js ${{ matrix.branch }}/compat
70+
mkdir -p ${{ matrix.branch }}/bundles
71+
cp tests/bundles/* ${{ matrix.branch }}/bundles
72+
mkdir -p ${{ matrix.branch }}/unit-browser
73+
cp tests/unit-browser/* ${{ matrix.branch }}/unit-browser
74+
- name: Save cached artifacts
75+
if: steps.artifacts-restore.outputs.cache-hit != 'true'
76+
uses: actions/cache/save@v4
77+
with:
78+
path: ${{ matrix.branch }}
79+
key: ${{ env.CACHE_KEY }}
80+
- name: Upload artifacts for branch ${{ matrix.branch }}
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: ${{ matrix.branch }}
84+
path: ${{ matrix.branch }}
85+
86+
combine-pages-and-deploy:
87+
needs: build-compat-pages
88+
runs-on: ubuntu-latest
89+
environment:
90+
name: github-pages
91+
url: ${{ steps.deployment.outputs.page_url }}
92+
steps:
93+
- uses: actions/checkout@v4
94+
- name: Download artifacts
95+
uses: actions/download-artifact@v4
96+
with:
97+
path: pages
98+
- name: Add docs
99+
run: cp -r docs/ pages/
100+
- name: Setup Pages
101+
uses: actions/configure-pages@v5
102+
- name: Upload GitHub Pages artifact
103+
uses: actions/upload-pages-artifact@v3
104+
with:
105+
path: pages
106+
- name: Deploy to GitHub Pages
107+
id: deployment
108+
uses: actions/deploy-pages@v4

scripts/bundle-tests/bundle-tests.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ await Promise.all([
55
--entry ../../tests/${ entry }.js \
66
--output-filename ${ output }.js \
77
`));
8+
9+
fs.copyFile('../../packages/core-js-bundle/index.js', '../../tests/bundles/core-js-bundle.js');
10+
11+
fs.copyFile('./node_modules/@slowcheetah/qunitjs-1/qunit/qunit.js', '../../tests/bundles/qunit.js');
12+
fs.copyFile('./node_modules/@slowcheetah/qunitjs-1/qunit/qunit.css', '../../tests/bundles/qunit.css');

scripts/bundle-tests/package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/bundle-tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "scripts/bundle-tests",
33
"devDependencies": {
4+
"@slowcheetah/qunitjs-1": "^1.23.1",
45
"babel-loader": "^10.0.0",
56
"webpack": "^5.99.5",
67
"webpack-cli": "^6.0.1"

tests/unit-browser/global.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<!DOCTYPE html>
22
<meta charset='UTF-8'>
33
<title>core-js</title>
4-
<link rel='stylesheet' href='../unit-karma/node_modules/qunit/qunit/qunit.css'>
4+
<link rel='stylesheet' href='../bundles/qunit.css'>
55
<div id='qunit'></div>
66
<div id='qunit-fixture'></div>
7-
<script src='../unit-karma/node_modules/qunit/qunit/qunit.js'></script>
7+
<script src='../bundles/qunit.js'></script>
88
<script>
99
window.USE_FUNCTION_CONSTRUCTOR = true;
1010
</script>
11-
<script src='../../packages/core-js-bundle/index.js'></script>
11+
<script src='../bundles/core-js-bundle.js'></script>
1212
<script>
1313
window.inspectSource = window['__core-js_shared__'].inspectSource;
1414
</script>

tests/unit-browser/pure.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!DOCTYPE html>
22
<meta charset='UTF-8'>
33
<title>core-js-pure</title>
4-
<link rel='stylesheet' href='../unit-karma/node_modules/qunit/qunit/qunit.css'>
4+
<link rel='stylesheet' href='../bundles/qunit.css'>
55
<div id='qunit'></div>
66
<div id='qunit-fixture'></div>
7-
<script src='../unit-karma/node_modules/qunit/qunit/qunit.js'></script>
7+
<script src='../bundles/qunit.js'></script>
88
<script>
99
window.USE_FUNCTION_CONSTRUCTOR = true;
1010
</script>

0 commit comments

Comments
 (0)