Skip to content

Commit 8c5b757

Browse files
committed
chore: migrate lint from circleci to github actions
1 parent 31dae03 commit 8c5b757

File tree

9 files changed

+271
-57
lines changed

9 files changed

+271
-57
lines changed

.circleci/config.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,6 @@ jobs:
206206
- store_test_results:
207207
path: /root/project/results/
208208

209-
lint:
210-
executor: node
211-
212-
steps:
213-
- downstream
214-
- run:
215-
name: Lint
216-
command: yarn lint
217-
- run: yarn analyze
218-
- run:
219-
name: Are there changes?
220-
command: git diff-files --exit-code
221-
222209
preview-docs:
223210
executor: node
224211
steps:
@@ -380,7 +367,6 @@ workflows:
380367
- test-chromium-memory
381368
- test-firefox
382369
- test-webkit
383-
- lint
384370
- hcm-visual:
385371
filters:
386372
branches:
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
name: Setup Job
22
description: Common setup for all jobs
3+
inputs:
4+
node-version:
5+
description: 'The Node.js version to use'
6+
required: false
7+
default: '20'
38
runs:
49
using: 'composite'
510
steps:
611
- name: Enable Corepack
712
shell: bash
813
run: corepack enable
914

10-
- name: Setup Node 20
15+
- name: Setup Node LTS version
1116
uses: actions/setup-node@v4
1217
with:
13-
node-version: '20'
18+
node-version: ${{ inputs.node-version }}
1419
cache: 'yarn'
1520
registry-url: 'https://registry.npmjs.org'
1621

22+
## --- YARN CACHE --- ##
23+
- name: Check for cached dependencies
24+
continue-on-error: true
25+
id: cache-dependencies
26+
uses: actions/cache@v4
27+
with:
28+
path: |
29+
.cache/yarn
30+
node_modules
31+
key: ${{ runner.os }}-node${{ inputs.node-version }}-${{ hashFiles('yarn.lock') }}
32+
33+
## --- INSTALL --- ##
1734
- name: Install dependencies
1835
shell: bash
19-
run: yarn --immutable
36+
run: yarn install --immutable

.github/workflows/build.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Build
2+
#
3+
# This workflow validates that the commit in question can be built successfully
4+
# in several environments:
5+
#
6+
# Systems: Ubuntu, MacOS, Windows
7+
# Node: 20
8+
#
9+
# After the build is successful, the compiled assets are uploaded as an artifact
10+
# to the workflow run. This allows us to download the compiled assets and use
11+
# them in other workflows.
12+
#
13+
# Note: we need to skip the nx cache b/c it does not contain the compiled assets
14+
#
15+
16+
on:
17+
workflow_dispatch:
18+
inputs:
19+
system:
20+
required: false
21+
default: 'macos-latest'
22+
node-version:
23+
required: false
24+
default: '20'
25+
experimental:
26+
required: false
27+
default: 'false'
28+
ref:
29+
description: 'The branch or tag to checkout'
30+
required: false
31+
workflow_call:
32+
inputs:
33+
system:
34+
required: false
35+
type: string
36+
default: 'macos-latest'
37+
node-version:
38+
required: false
39+
type: string
40+
default: '20'
41+
experimental:
42+
required: false
43+
type: boolean
44+
default: false
45+
ref:
46+
description: 'The branch or tag to checkout'
47+
required: false
48+
type: string
49+
default: ${{ github.head_ref }}
50+
51+
permissions:
52+
contents: read
53+
pull-requests: write
54+
55+
defaults:
56+
run:
57+
shell: bash
58+
59+
jobs:
60+
# ---------- Validate build for various environments ---------- #
61+
build:
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
system:
66+
- ${{ inputs.system }}
67+
node-version:
68+
- ${{ inputs.node-version }}
69+
experimental:
70+
- ${{ inputs.experimental }}
71+
runs-on: ${{ matrix.system }}
72+
continue-on-error: ${{ matrix.experimental }}
73+
timeout-minutes: 10
74+
name: Build ${{ matrix.system }}, node v${{ matrix.node-version }}
75+
steps:
76+
- name: Checkout PR branch
77+
uses: actions/checkout@v4
78+
with:
79+
ref: ${{ inputs.ref || github.head_ref }}
80+
fetch-depth: 0
81+
82+
- name: Setup Job and Install Dependencies
83+
uses: ./.github/actions/setup-job
84+
with:
85+
node-version: ${{ matrix.node-version }}
86+
87+
- name: Build the project
88+
if: always()
89+
run: yarn build
90+
91+
# This step will evaluate the repo status and report the change
92+
# If there are changes, capture the changes and upload them as an artifact
93+
- name: Check if there are changes
94+
if: always()
95+
run: |
96+
if [[ -z $(git status --porcelain) ]]; then
97+
echo "No changes detected"
98+
exit 0
99+
else
100+
echo "Changes detected"
101+
git status
102+
exit 1
103+
fi

.github/workflows/coveralls.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
name: Code coverage
2-
32
on:
3+
workflow_dispatch:
4+
workflow_call:
5+
46
push:
57
branches:
68
- main
7-
pull_request:
8-
branches:
9-
- main
109

1110
jobs:
1211
code-coverage-report:
@@ -15,6 +14,8 @@ jobs:
1514
steps:
1615
- name: Checkout PR branch
1716
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
1819

1920
- name: Setup Job and Install Dependencies
2021
uses: ./.github/actions/setup-job

.github/workflows/development.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: PR verification
2+
# -------------------------------------------------------------
3+
# This workflow will build and verify pull requests. It will:
4+
# - Build the branch and fail if the build fails
5+
# - Run code coverage tests on the PR branch
6+
# - Lint the PR branch
7+
# -------------------------------------------------------------
8+
9+
on:
10+
merge_group:
11+
push:
12+
branches: [main]
13+
pull_request:
14+
branches: [main]
15+
types:
16+
- opened
17+
- synchronize
18+
- reopened
19+
- labeled
20+
- unlabeled
21+
- auto_merge_enabled
22+
23+
permissions:
24+
contents: read
25+
pull-requests: write
26+
27+
concurrency:
28+
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
29+
cancel-in-progress: true
30+
31+
defaults:
32+
run:
33+
shell: bash
34+
35+
jobs:
36+
# -------------------------------------------------------------
37+
# Validate build for various environments
38+
# -------------------------------------------------------------
39+
verify_builds:
40+
name: Verify build
41+
# Check that the PR is not in draft mode (or if it is, that it has the run_ci label to force a build)
42+
if: ${{ github.event.pull_request.draft != 'true' || contains(github.event.pull_request.labels.*.name, 'run_ci') }}
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
system:
47+
- macos-latest
48+
- ubuntu-latest
49+
# - windows-latest
50+
node-version:
51+
- 20
52+
uses: ./.github/workflows/build.yml
53+
with:
54+
system: ${{ matrix.system }}
55+
node-version: ${{ matrix.node-version }}
56+
secrets: inherit
57+
58+
coverage:
59+
name: Code coverage
60+
# Check that the PR is not in draft mode (or if it is, that it has the run_ci label to force a build)
61+
if: ${{ github.event.pull_request.draft != 'true' || contains(github.event.pull_request.labels.*.name, 'run_ci') }}
62+
uses: ./.github/workflows/coveralls.yml
63+
secrets: inherit
64+
65+
# -------------------------------------------------------------
66+
# Lint pre-compiled assets for consistency
67+
# -------------------------------------------------------------
68+
lint:
69+
name: Lint
70+
if: ${{ contains(github.event.pull_request.labels.*.name, 'skip_lint') == false }}
71+
uses: ./.github/workflows/lint.yml
72+
secrets: inherit

.github/workflows/lint.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Lint
2+
#
3+
# This workflow lints the UI library and reports back any suggested fixes
4+
#
5+
6+
on:
7+
workflow_dispatch:
8+
workflow_call:
9+
10+
permissions:
11+
contents: read
12+
pull-requests: write
13+
14+
defaults:
15+
run:
16+
shell: bash
17+
18+
jobs:
19+
# --- Lint pre-compiled assets for consistency --- #
20+
lint:
21+
name: Lint
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 5
24+
outputs:
25+
eslint_diff_files: ${{ steps.changed-files.outputs.eslint_diff_files }}
26+
stylelint_diff_files: ${{ steps.changed-files.outputs.stylelint_diff_files }}
27+
steps:
28+
# install but don't build - we're linting pre-compiled assets
29+
- name: Check out code
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 2
33+
34+
- name: Setup Job and Install Dependencies
35+
uses: ./.github/actions/setup-job
36+
37+
- name: Check for changed files
38+
id: changed-files
39+
run: |
40+
echo "eslint=$(git diff --name-only --diff-filter=d -- "projects/documentation/**/*.ts" "packages/**/*.ts" "tools/**/*.ts" | xargs)" >> $GITHUB_OUTPUT
41+
echo "stylelint=$(git diff --name-only --diff-filter=d -- "packages/**/*.css" "tools/**/*.css" | xargs)" >> $GITHUB_OUTPUT
42+
43+
- name: echo eslint changed files
44+
run: echo ${{ steps.changed-files.outputs.eslint }}
45+
46+
- name: echo stylelint changed files
47+
run: echo ${{ steps.changed-files.outputs.stylelint }}
48+
49+
- name: Lint component styles
50+
uses: reviewdog/action-stylelint@v1.30.0
51+
if: ${{ steps.changed-files.outputs.stylelint != '' }}
52+
with:
53+
fail_level: error
54+
filter_mode: diff_context
55+
level: error
56+
reporter: github-pr-review
57+
stylelint_input: '${{ steps.changed-files.outputs.stylelint }}'
58+
stylelint_config: '${{ github.workspace }}/.stylelintrc.json'
59+
60+
- name: Run eslint on packages and stories
61+
uses: reviewdog/action-eslint@v1.33.0
62+
if: ${{ steps.changed-files.outputs.eslint != '' }}
63+
with:
64+
fail_level: error
65+
level: error
66+
reporter: github-pr-review
67+
filter_mode: diff_context
68+
eslint_flags: '${{ steps.changed-files.outputs.eslint }}'

.github/workflows/pr-update.yml

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"@rollup/plugin-json": "^6.0.1",
117117
"@rollup/plugin-node-resolve": "^15.2.3",
118118
"@sindresorhus/slugify": "^2.1.1",
119-
"@spectrum-web-components/eslint-plugin": "file:./linters/eslint",
119+
"@spectrum-web-components/eslint-plugin": "1.3.0",
120120
"@storybook/addon-a11y": "^7.5.0",
121121
"@storybook/addon-designs": "^8.0.0",
122122
"@storybook/addon-essentials": "^7.5.0",

yarn.lock

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ __metadata:
214214
"@rollup/plugin-json": "npm:^6.0.1"
215215
"@rollup/plugin-node-resolve": "npm:^15.2.3"
216216
"@sindresorhus/slugify": "npm:^2.1.1"
217-
"@spectrum-web-components/eslint-plugin": "file:./linters/eslint"
217+
"@spectrum-web-components/eslint-plugin": "npm:1.3.0"
218218
"@storybook/addon-a11y": "npm:^7.5.0"
219219
"@storybook/addon-designs": "npm:^8.0.0"
220220
"@storybook/addon-essentials": "npm:^7.5.0"
@@ -8412,14 +8412,7 @@ __metadata:
84128412
languageName: unknown
84138413
linkType: soft
84148414

8415-
"@spectrum-web-components/eslint-plugin@file:./linters/eslint::locator=%40adobe%2Fspectrum-web-components%40workspace%3A.":
8416-
version: 1.3.0
8417-
resolution: "@spectrum-web-components/eslint-plugin@file:./linters/eslint#./linters/eslint::hash=850176&locator=%40adobe%2Fspectrum-web-components%40workspace%3A."
8418-
checksum: 10c0/49197a16df8435d740d61d048a43fea9accdf3dc4c13e2c2f4e986ef5e5474a325f19fd7406814cb6aa0033da949da4b4922b5127c18855bd4bb69880bae7dda
8419-
languageName: node
8420-
linkType: hard
8421-
8422-
"@spectrum-web-components/eslint-plugin@workspace:linters/eslint":
8415+
"@spectrum-web-components/eslint-plugin@npm:1.3.0, @spectrum-web-components/eslint-plugin@workspace:linters/eslint":
84238416
version: 0.0.0-use.local
84248417
resolution: "@spectrum-web-components/eslint-plugin@workspace:linters/eslint"
84258418
languageName: unknown

0 commit comments

Comments
 (0)