Skip to content

Commit 672afc7

Browse files
authored
ci: update ci to use reusables (#776)
* ci: update ci to use reusables * ci: split build, test, and typecheck * ci: add node 22 for typechecking * build: cleanup tsconfigs * ci: shorter names * ci: use reusable-typecheck
1 parent 7da45f8 commit 672afc7

15 files changed

+58
-357
lines changed

.github/problemMatchers/eslint.json

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

.github/problemMatchers/tsc.json

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

.github/workflows/auto-deprecate.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,8 @@ on:
77
jobs:
88
auto-deprecate:
99
name: NPM Auto Deprecate
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: Checkout Project
13-
uses: actions/checkout@v4
14-
- name: Use Node.js v20
15-
uses: actions/setup-node@v4
16-
with:
17-
node-version: 20
18-
cache: yarn
19-
registry-url: https://registry.npmjs.org/
20-
- name: Install Dependencies
21-
run: yarn --immutable
22-
- name: Deprecate versions
23-
run: yarn npm-deprecate
24-
env:
25-
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
10+
uses: sapphiredev/.github/.github/workflows/reusable-yarn-job.yml@main
11+
with:
12+
script-name: npm-deprecate
13+
secrets:
14+
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Code Scanning
1+
name: Code scanning
22

33
on:
44
push:
@@ -11,18 +11,6 @@ on:
1111
- cron: '30 1 * * 0'
1212

1313
jobs:
14-
CodeQL:
15-
runs-on: ubuntu-latest
16-
17-
steps:
18-
- name: Checkout repository
19-
uses: actions/checkout@v4
20-
21-
- name: Initialize CodeQL
22-
uses: github/codeql-action/init@v3
23-
24-
- name: Autobuild
25-
uses: github/codeql-action/autobuild@v3
26-
27-
- name: Perform CodeQL Analysis
28-
uses: github/codeql-action/analyze@v3
14+
codeql:
15+
name: Analysis
16+
uses: sapphiredev/.github/.github/workflows/reusable-codeql.yml@main

.github/workflows/continuous-delivery.yml

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,10 @@ on:
2121
jobs:
2222
Publish:
2323
name: Publish Next to npm
24-
runs-on: ubuntu-latest
25-
steps:
26-
- name: Checkout Project
27-
uses: actions/checkout@v4
28-
with:
29-
fetch-depth: 0
30-
repository: ${{ github.event.inputs.repository || 'sapphiredev/framework' }}
31-
ref: ${{ github.event.inputs.ref || 'main' }}
32-
- name: Add TypeScript problem matcher
33-
run: echo "::add-matcher::.github/problemMatchers/tsc.json"
34-
- name: Use Node.js v20
35-
uses: actions/setup-node@v4
36-
with:
37-
node-version: 20
38-
cache: yarn
39-
registry-url: https://registry.yarnpkg.com/
40-
- name: Install Dependencies
41-
run: yarn --immutable
42-
- name: Bump Version & Publish
43-
run: |
44-
# Resolve the tag to be used. "next" for push events, "pr-{prNumber}" for dispatch events.
45-
TAG=$([[ ${{ github.event_name }} == 'push' ]] && echo 'next' || echo 'pr-${{ github.event.inputs.prNumber }}')
46-
47-
yarn config set npmAuthToken ${NODE_AUTH_TOKEN}
48-
yarn config set npmPublishRegistry "https://registry.yarnpkg.com"
49-
50-
yarn bump --preid "${TAG}.$(git rev-parse --verify --short HEAD)" --skip-changelog
51-
52-
yarn npm publish --tag ${TAG}
53-
env:
54-
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
55-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
uses: sapphiredev/.github/.github/workflows/reusable-continuous-delivery.yml@main
25+
with:
26+
pr-number: ${{ github.event.inputs.prNumber }}
27+
ref: ${{ github.event.inputs.ref }}
28+
repository: ${{ github.event.inputs.repository }}
29+
secrets:
30+
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
Lines changed: 26 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Continuous Integration
1+
name: CI
22

33
on:
44
push:
@@ -7,78 +7,35 @@ on:
77
pull_request:
88

99
jobs:
10-
Linting:
10+
linting:
1111
name: Linting
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Checkout Project
15-
uses: actions/checkout@v4
16-
- name: Add problem matcher
17-
run: echo "::add-matcher::.github/problemMatchers/eslint.json"
18-
- name: Use Node.js v20
19-
uses: actions/setup-node@v4
20-
with:
21-
node-version: 20
22-
cache: yarn
23-
registry-url: https://registry.npmjs.org/
24-
- name: Install Dependencies
25-
run: yarn --immutable
26-
- name: Run ESLint
27-
run: yarn lint --fix=false
12+
uses: sapphiredev/.github/.github/workflows/reusable-lint.yml@main
2813

2914
docs:
30-
name: Generate Documentation
31-
runs-on: ubuntu-latest
32-
steps:
33-
- name: Checkout Project
34-
uses: actions/checkout@v4
35-
- name: Use Node.js v20
36-
uses: actions/setup-node@v4
37-
with:
38-
node-version: 20
39-
cache: yarn
40-
registry-url: https://registry.npmjs.org/
41-
- name: Install Dependencies
42-
run: yarn --immutable
43-
- name: Generate Documentation
44-
run: yarn docs
15+
name: Docgen
16+
uses: sapphiredev/.github/.github/workflows/reusable-yarn-job.yml@main
17+
with:
18+
script-name: docs
4519

46-
BuildingAndTesting:
47-
name: Building and Testing with node v${{ matrix.node }}
48-
runs-on: ubuntu-latest
20+
build:
21+
name: Building
22+
uses: sapphiredev/.github/.github/workflows/reusable-build.yml@main
23+
24+
test:
25+
name: Tests
26+
uses: sapphiredev/.github/.github/workflows/reusable-tests.yml@main
27+
with:
28+
enable-sonar: true
29+
secrets:
30+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
31+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
32+
33+
typecheck:
34+
name: Typecheck node v${{ matrix.node }}
4935
strategy:
5036
fail-fast: false
5137
matrix:
52-
node: [18, 19, 20, 21]
53-
steps:
54-
- name: Checkout Project
55-
uses: actions/checkout@v4
56-
with:
57-
fetch-depth: 0
58-
- name: Add problem matcher
59-
run: echo "::add-matcher::.github/problemMatchers/tsc.json"
60-
- name: Use Node.js ${{ matrix.node }}
61-
uses: actions/setup-node@v4
62-
with:
63-
node-version: ${{ matrix.node }}
64-
cache: yarn
65-
registry-url: https://registry.npmjs.org/
66-
- name: Install Dependencies
67-
run: yarn --immutable
68-
- name: Typecheck And Build Code
69-
run: yarn typecheck && yarn build
70-
- name: Run tests
71-
run: yarn test
72-
- name: SonarQube Scan
73-
if: matrix.node == 20
74-
uses: sonarsource/sonarqube-scan-action@master
75-
env:
76-
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
77-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
78-
- name: Quality Gate
79-
if: matrix.node == 20
80-
uses: sonarsource/sonarqube-quality-gate-action@master
81-
timeout-minutes: 5
82-
env:
83-
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
84-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
38+
node: [18, 19, 20, 21, 22]
39+
uses: sapphiredev/.github/.github/workflows/reusable-typecheck.yml@main
40+
with:
41+
node-version: ${{ matrix.node }}

.github/workflows/deprecate-on-merge.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@ jobs:
1212
steps:
1313
- name: Checkout Project
1414
uses: actions/checkout@v4
15-
- name: Use Node.js v20
16-
uses: actions/setup-node@v4
15+
- name: Install dependencies
16+
uses: sapphiredev/.github/actions/install-yarn-dependencies@main
1717
with:
1818
node-version: 20
19-
cache: yarn
20-
registry-url: https://registry.npmjs.org/
21-
- name: Install Dependencies
22-
run: yarn --immutable
2319
- name: Deprecate versions
2420
run: yarn npm-deprecate --name "*pr-${PR_NUMBER}*" -d -v
2521
env:

.github/workflows/documentation.yml

Lines changed: 4 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -12,101 +12,7 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
build:
16-
name: Build Documentation
17-
runs-on: ubuntu-latest
18-
19-
if: github.repository_owner == 'sapphiredev'
20-
outputs:
21-
NAME: ${{ steps.env.outputs.NAME }}
22-
TYPE: ${{ steps.env.outputs.TYPE }}
23-
SHA: ${{ steps.env.outputs.SHA }}
24-
steps:
25-
- name: Checkout Project
26-
uses: actions/checkout@v4
27-
- name: Use Node.js v20
28-
uses: actions/setup-node@v4
29-
with:
30-
node-version: 20
31-
cache: yarn
32-
registry-url: https://registry.npmjs.org/
33-
- name: Install Dependencies
34-
run: yarn --immutable
35-
- name: Build Documentation
36-
run: yarn docs
37-
- name: Upload Documentation Artifacts
38-
uses: actions/upload-artifact@v4
39-
with:
40-
name: docs
41-
path: docs/api.json
42-
- name: Set Output
43-
id: env
44-
run: |
45-
echo "NAME=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
46-
echo "TYPE=${GITHUB_REF_TYPE}" >> $GITHUB_OUTPUT
47-
echo "SHA=${GITHUB_SHA}" >> $GITHUB_OUTPUT
48-
upload:
49-
name: Upload Documentation
50-
needs: build
51-
runs-on: ubuntu-latest
52-
env:
53-
NAME: ${{ needs.build.outputs.NAME }}
54-
TYPE: ${{ needs.build.outputs.TYPE }}
55-
SHA: ${{ needs.build.outputs.SHA }}
56-
steps:
57-
- name: Checkout Project
58-
uses: actions/checkout@v4
59-
- name: Use Node.js v20
60-
uses: actions/setup-node@v4
61-
with:
62-
node-version: 20
63-
cache: yarn
64-
registry-url: https://registry.yarnpkg.org/
65-
- name: Install Dependencies
66-
run: yarn --immutable
67-
- name: Download Documentation Artifacts
68-
uses: actions/download-artifact@v4
69-
with:
70-
name: docs
71-
path: docs
72-
- name: Checkout Documentation Project
73-
uses: actions/checkout@v4
74-
with:
75-
repository: 'sapphiredev/docs'
76-
token: ${{ secrets.SKYRA_TOKEN }}
77-
path: 'out'
78-
79-
- name: Move Documentation
80-
if: ${{ env.TYPE == 'tag' }}
81-
env:
82-
SEMVER: ${{ env.NAME }}
83-
run: |
84-
mkdir -p out/framework
85-
mv docs/api.json out/docs/framework/${SEMVER}.json
86-
- name: Move Documentation
87-
if: ${{ env.TYPE == 'branch' }}
88-
run: |
89-
mkdir -p out/framework
90-
mv docs/api.json out/docs/framework/${NAME}.json
91-
92-
- name: Commit & Push
93-
uses: nick-fields/retry@v3
94-
with:
95-
max_attempts: 3
96-
retry_on: error
97-
timeout_minutes: 1
98-
command: |
99-
cd out
100-
git add .
101-
if git diff-index --quiet HEAD --; then
102-
echo "No changes to commit, exiting with code 0"
103-
exit 0;
104-
else
105-
git config user.name github-actions[bot]
106-
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
107-
git config rebase.autostash true
108-
git config pull.rebase true
109-
git commit -m "docs(framework): build for ${TYPE} ${NAME}: ${SHA}" || true
110-
git pull
111-
git push
112-
fi
15+
docgen:
16+
uses: sapphiredev/.github/.github/workflows/reusable-docgen.yml@main
17+
with:
18+
project-name: framework

.github/workflows/labelsync.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,4 @@ on:
77

88
jobs:
99
label_sync:
10-
name: Automatic Label Synchronization
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: Checkout Project
14-
uses: actions/checkout@v4
15-
with:
16-
sparse-checkout: .github/labels.yml
17-
sparse-checkout-cone-mode: false
18-
repository: 'sapphiredev/.github'
19-
- name: Run Label Sync
20-
uses: crazy-max/ghaction-github-labeler@v5
21-
with:
22-
github-token: ${{ secrets.GITHUB_TOKEN }}
23-
yaml-file: .github/labels.yml
10+
uses: sapphiredev/.github/.github/workflows/reusable-labelsync.yml@main

0 commit comments

Comments
 (0)