Skip to content

Commit a6fbc41

Browse files
committed
New build system. Better type checking (#303)
1 parent 4eeafc9 commit a6fbc41

16 files changed

Lines changed: 317 additions & 314 deletions

File tree

.circleci/config.yml

Lines changed: 0 additions & 161 deletions
This file was deleted.

.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: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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+
outputs:
87+
already_published: ${{ steps.check_tag.outputs.already_published }}
88+
steps:
89+
- uses: actions/checkout@v4
90+
- uses: actions/setup-node@v4
91+
with:
92+
node-version: lts/*
93+
- run: node -v
94+
- name: Check if remote tag already exists
95+
id: check_tag
96+
run: |
97+
TAG="v$(jq -r '.version' package.json)"
98+
if git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null; then
99+
echo "Tag ${TAG} already exists on origin. Skipping publish and pages."
100+
echo "already_published=true" >> "$GITHUB_OUTPUT"
101+
else
102+
echo "already_published=false" >> "$GITHUB_OUTPUT"
103+
fi
104+
- name: Set git user
105+
if: steps.check_tag.outputs.already_published == 'false'
106+
run: |
107+
git config --global user.name "$(git show -s --format=%an)"
108+
git config --global user.email "$(git show -s --format=%ae)"
109+
- run: npm i
110+
if: steps.check_tag.outputs.already_published == 'false'
111+
- name: Add publish token
112+
if: steps.check_tag.outputs.already_published == 'false'
113+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
114+
- run: npm publish
115+
if: steps.check_tag.outputs.already_published == 'false'
116+
- name: Add git tag
117+
if: steps.check_tag.outputs.already_published == 'false'
118+
run: git tag -a "v$(cat package.json | jq '.version' -r)" -m "$(git show -s --format=%B | tr -d '\n')"
119+
- run: git push origin --tags
120+
if: steps.check_tag.outputs.already_published == 'false'
121+
122+
pages:
123+
needs: publish
124+
runs-on: ubuntu-latest
125+
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && needs.publish.outputs.already_published == 'false'
126+
steps:
127+
- uses: actions/checkout@v4
128+
- uses: actions/setup-node@v4
129+
with:
130+
node-version: lts/*
131+
- run: npm i
132+
- run: npm run page
133+
- name: Copy github workflows config
134+
run: mkdir -p docs/.github/workflows && cp -r .github/workflows/* docs/.github/workflows/
135+
- name: Post to gh-pages
136+
run: bash ./scripts/gh-pages/procedure.sh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ node_modules
33
# Auomatically built files
44
/src/pattern.ts
55
/index*
6+
/browser*
67
/*.d.ts
78
/fixtures/index.json
89
/AUTHORS

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [5.1.37](https://github.com/omrilotan/isbot/compare/v5.1.36...v5.1.37)
4+
5+
- Better checking for non empty strings in the interface functions
6+
- [Internal] Build with tsup
7+
38
## [5.1.36](https://github.com/omrilotan/isbot/compare/v5.1.35...v5.1.36)
49

510
- [Pattern] Pattern updates

0 commit comments

Comments
 (0)