Skip to content

Commit 63a196c

Browse files
committed
Add github workflows
1 parent c4b2d4d commit 63a196c

4 files changed

Lines changed: 154 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: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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+
artifact-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+
35+
tests:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: actions/setup-node@v4
40+
with:
41+
node-version: lts/*
42+
- run: npm i
43+
- run: npm run build
44+
- run: npm run format
45+
- name: Push autofixes
46+
if: always() && github.event_name == 'push'
47+
run: |
48+
if ! git diff --quiet; then
49+
git config --global user.email omrilotan@users.noreply.github.com
50+
git config --global user.name omrilotan
51+
git add -A
52+
git commit -m "Autofix"
53+
git push origin HEAD:${GITHUB_REF#refs/heads/}
54+
fi
55+
- run: npm t
56+
57+
compatibility:
58+
needs: build
59+
runs-on: ubuntu-latest
60+
strategy:
61+
matrix:
62+
node-version:
63+
- '18.20'
64+
- '20.19'
65+
- '22.18'
66+
- '24.6'
67+
steps:
68+
- uses: actions/checkout@v4
69+
- uses: actions/setup-node@v4
70+
with:
71+
node-version: ${{ matrix.node-version }}
72+
- run: node -v
73+
- run: npm i
74+
- uses: actions/download-artifact@v4
75+
with:
76+
name: build
77+
- run: npm t -- spec
78+
79+
publish:
80+
needs:
81+
- tests
82+
- compatibility
83+
runs-on: ubuntu-latest
84+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
85+
steps:
86+
- uses: actions/checkout@v4
87+
- uses: actions/setup-node@v4
88+
with:
89+
node-version: lts/*
90+
- run: node -v
91+
- name: Stop if remote tag already exists
92+
run: |
93+
[ -z "$(git ls-remote --tags origin | grep -F $(cat package.json | jq '.version' -r) | tr -d '\n')" ] || exit 0
94+
- name: Set git user
95+
run: |
96+
git config --global user.name "$(git show -s --format=%an)"
97+
git config --global user.email "$(git show -s --format=%ae)"
98+
- run: npm i
99+
- name: Add publish token
100+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
101+
- run: npm publish
102+
- name: Add git tag
103+
run: git tag -a "v$(cat package.json | jq '.version' -r)" -m "$(git show -s --format=%B | tr -d '\n')"
104+
- run: git push origin --tags
105+
106+
pages:
107+
needs: publish
108+
runs-on: ubuntu-latest
109+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
110+
steps:
111+
- uses: actions/checkout@v4
112+
- uses: actions/setup-node@v4
113+
with:
114+
node-version: lts/*
115+
- run: npm i
116+
- run: npm run page
117+
- name: Copy github workflows config
118+
run: mkdir -p docs/.github/workflows && cp -r .github/workflows/* docs/.github/workflows/
119+
- name: Post to gh-pages
120+
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)