Skip to content

Commit a65a8c3

Browse files
committed
Add github workflows
1 parent c4b2d4d commit a65a8c3

4 files changed

Lines changed: 155 additions & 2 deletions

File tree

.github/workflows/periodic.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Periodic Tests
2+
3+
permissions:
4+
issues: write
5+
6+
on:
7+
schedule:
8+
- cron: '0 9 * * 1'
9+
10+
jobs:
11+
periodic:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: lts/*
18+
- run: npm i --ignore-scripts
19+
- run: npm run prepare -- --force
20+
- name: Run tests
21+
id: test
22+
continue-on-error: true
23+
run: npm t
24+
- name: Create issue on test failure
25+
if: steps.test.outcome == 'failure'
26+
run: |
27+
gh issue create \
28+
--title "Automated issue for failing periodic tests" \
29+
--body "This issue is automatically created. The tests are failing on run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
30+
--assignee omrilotan \
31+
--label automated \
32+
--label maintenance

.github/workflows/test.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Test and Publish Workflow
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
- '!gh-pages'
11+
pull_request:
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: lts/*
21+
- run: npm i
22+
- run: npm run prepare -- --force
23+
- run: npm run build
24+
- uses: actions/upload-artifact@v4
25+
with:
26+
name: build
27+
path: |
28+
index.js
29+
index.mjs
30+
index.iife.js
31+
index.d.ts
32+
browser.global.js
33+
browser.global.js.map
34+
retention-days: 1
35+
36+
tests:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-node@v4
41+
with:
42+
node-version: lts/*
43+
- run: npm i
44+
- run: npm run build
45+
- run: npm run format
46+
- name: Push autofixes
47+
if: always() && github.event_name == 'push'
48+
run: |
49+
if ! git diff --quiet; then
50+
git config --global user.email omrilotan@users.noreply.github.com
51+
git config --global user.name omrilotan
52+
git add -A
53+
git commit -m "Autofix"
54+
git push origin HEAD:${GITHUB_REF#refs/heads/}
55+
fi
56+
- run: npm t
57+
58+
compatibility:
59+
needs: build
60+
runs-on: ubuntu-latest
61+
strategy:
62+
matrix:
63+
node-version:
64+
- '18.20'
65+
- '20.19'
66+
- '22.18'
67+
- '24.6'
68+
steps:
69+
- uses: actions/checkout@v4
70+
- uses: actions/setup-node@v4
71+
with:
72+
node-version: ${{ matrix.node-version }}
73+
- run: node -v
74+
- run: npm i
75+
- uses: actions/download-artifact@v4
76+
with:
77+
name: build
78+
- run: npm t -- spec
79+
80+
publish:
81+
needs:
82+
- tests
83+
- compatibility
84+
runs-on: ubuntu-latest
85+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
86+
steps:
87+
- uses: actions/checkout@v4
88+
- uses: actions/setup-node@v4
89+
with:
90+
node-version: lts/*
91+
- run: node -v
92+
- name: Stop if remote tag already exists
93+
run: |
94+
[ -z "$(git ls-remote --tags origin | grep -F $(cat package.json | jq '.version' -r) | tr -d '\n')" ] || exit 0
95+
- name: Set git user
96+
run: |
97+
git config --global user.name "$(git show -s --format=%an)"
98+
git config --global user.email "$(git show -s --format=%ae)"
99+
- run: npm i
100+
- name: Add publish token
101+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
102+
- run: npm publish
103+
- name: Add git tag
104+
run: git tag -a "v$(cat package.json | jq '.version' -r)" -m "$(git show -s --format=%B | tr -d '\n')"
105+
- run: git push origin --tags
106+
107+
pages:
108+
needs: publish
109+
runs-on: ubuntu-latest
110+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
111+
steps:
112+
- uses: actions/checkout@v4
113+
- uses: actions/setup-node@v4
114+
with:
115+
node-version: lts/*
116+
- run: npm i
117+
- run: npm run page
118+
- name: Copy github workflows config
119+
run: mkdir -p docs/.github/workflows && cp -r .github/workflows/* docs/.github/workflows/
120+
- name: Post to gh-pages
121+
run: bash ./scripts/gh-pages/procedure.sh

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@
7272
"yaml": "^2.8.0"
7373
},
7474
"overrides": {
75-
"typescript": "$typescript"
75+
"typescript": "^6.0.2"
7676
}
7777
}

scripts/format/procedure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ echo "→ Sort lists"
77
failures=$((failures + $?))
88

99
echo "→ Format files"
10-
prettier --write .
10+
npx prettier --write .
1111
failures=$((failures + $?))
1212

1313
echo "→ Number of failures: ${failures}"

0 commit comments

Comments
 (0)