Skip to content

Commit d949764

Browse files
committed
add linters
1 parent 91b33b7 commit d949764

File tree

6 files changed

+261
-73
lines changed

6 files changed

+261
-73
lines changed

.github/workflows/check-dist.yml

+49-30
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,72 @@
1-
# `dist/index.js` is a special file in Actions.
2-
# When you reference an action with `uses:` in a workflow,
3-
# `index.js` is the code that will run.
4-
# For our project, we generate this file through a build process from other source files.
5-
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
6-
name: Check dist/
1+
# In TypeScript actions, `dist/` is a special directory. When you reference
2+
# an action with the `uses:` property, `dist/index.js` is the code that will be
3+
# run. For this project, the `dist/index.js` file is transpiled from other
4+
# source files. This workflow ensures the `dist/` directory contains the
5+
# expected transpiled code.
6+
#
7+
# If this workflow is run from a feature branch, it will act as an additional CI
8+
# check and fail if the checked-in `dist/` directory does not match what is
9+
# expected from the build.
10+
name: Check Transpiled JavaScript
711

812
on:
13+
pull_request:
14+
branches:
15+
- main
916
push:
1017
branches:
1118
- main
12-
paths-ignore:
13-
- '**.md'
14-
pull_request:
15-
paths-ignore:
16-
- '**.md'
17-
workflow_dispatch:
19+
20+
permissions:
21+
contents: read
1822

1923
jobs:
2024
check-dist:
25+
name: Check dist/
2126
runs-on: ubuntu-latest
2227

2328
steps:
24-
- uses: actions/checkout@v4
29+
- name: Checkout
30+
id: checkout
31+
uses: actions/checkout@v4
2532

26-
- name: Set Node.js 16.x
27-
uses: actions/setup-node@v4.0.2
33+
- name: Setup Node.js
34+
id: setup-node
35+
uses: actions/setup-node@v4
2836
with:
29-
node-version: 16.x
37+
node-version-file: .node-version
38+
cache: npm
3039

31-
- name: Install dependencies
40+
- name: Install Dependencies
41+
id: install
3242
run: npm ci
3343

34-
- name: Rebuild the dist/ directory
35-
run: |
36-
npm run build
37-
npm run package
44+
- name: Build dist/ Directory
45+
id: build
46+
run: npm run bundle
3847

39-
- name: Compare the expected and actual dist/ directories
48+
# This will fail the workflow if the `dist/` directory is different than
49+
# expected.
50+
- name: Compare Directories
51+
id: diff
4052
run: |
41-
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
42-
echo "Detected uncommitted changes after build. See status below:"
43-
git diff
53+
if [ ! -d dist/ ]; then
54+
echo "Expected dist/ directory does not exist. See status below:"
55+
ls -la ./
56+
exit 1
57+
fi
58+
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
59+
echo "Detected uncommitted changes after build. See status below:"
60+
git diff --ignore-space-at-eol --text dist/
4461
exit 1
4562
fi
46-
id: diff
4763
48-
# If index.js was different than expected, upload the expected version as an artifact
49-
- uses: actions/upload-artifact@v4
50-
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
64+
# If `dist/` was different than expected, upload the expected version as a
65+
# workflow artifact.
66+
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
67+
name: Upload Artifact
68+
id: upload
69+
uses: actions/upload-artifact@v4
5170
with:
5271
name: dist
53-
path: dist/
72+
path: dist/

.github/workflows/ci.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Continuous Integration
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
test-typescript:
16+
name: TypeScript Tests
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
id: checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js
25+
id: setup-node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version-file: .node-version
29+
cache: pnpm
30+
31+
- name: Install Dependencies
32+
id: pnpm-ci
33+
run: pnpm ci
34+
35+
- name: Check Format
36+
id: pnpm-format-check
37+
run: pnpm run format:check
38+
39+
- name: Lint
40+
id: pnpm-lint
41+
run: pnpm run lint
42+
43+
- name: Test
44+
id: pnpm-ci-test
45+
run: pnpm run ci-test
46+
47+
test-action:
48+
name: GitHub Actions Test
49+
runs-on: ubuntu-latest
50+
51+
steps:
52+
- name: Checkout
53+
id: checkout
54+
uses: actions/checkout@v4
55+
56+
- name: Test Local Action
57+
id: test-action
58+
uses: ./
59+
with:
60+
milliseconds: 2000
61+
62+
- name: Print Output
63+
id: output
64+
run: echo "${{ steps.test-action.outputs.time }}"

.github/workflows/codeql-analysis.yml

+20-43
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,48 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
6-
#
7-
# ******** NOTE ********
8-
# We have attempted to detect the languages in your repository. Please check
9-
# the `language` matrix defined below to confirm you have the correct set of
10-
# supported CodeQL languages.
11-
#
12-
name: 'CodeQL'
1+
name: CodeQL
132

143
on:
15-
push:
16-
branches: [main]
174
pull_request:
18-
# The branches below must be a subset of the branches above
19-
branches: [main]
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
2010
schedule:
2111
- cron: '31 7 * * 3'
2212

13+
permissions:
14+
actions: read
15+
checks: write
16+
contents: read
17+
security-events: write
18+
2319
jobs:
2420
analyze:
2521
name: Analyze
2622
runs-on: ubuntu-latest
27-
permissions:
28-
actions: read
29-
contents: read
30-
security-events: write
3123

3224
strategy:
3325
fail-fast: false
3426
matrix:
35-
language: ['TypeScript']
36-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37-
# Learn more about CodeQL language support at https://git.io/codeql-language-support
27+
language:
28+
- TypeScript
3829

3930
steps:
40-
- name: Checkout repository
31+
- name: Checkout
32+
id: checkout
4133
uses: actions/checkout@v4
4234

43-
# Initializes the CodeQL tools for scanning.
4435
- name: Initialize CodeQL
36+
id: initialize
4537
uses: github/codeql-action/init@v3
4638
with:
4739
languages: ${{ matrix.language }}
4840
source-root: src
49-
# If you wish to specify custom queries, you can do so here or in a config file.
50-
# By default, queries listed here will override any specified in a config file.
51-
# Prefix the list here with "+" to use these queries and those in the config file.
52-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
5341

54-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55-
# If this step fails, then you should remove it and run the build manually (see below)
5642
- name: Autobuild
43+
id: autobuild
5744
uses: github/codeql-action/autobuild@v3
5845

59-
# ℹ️ Command-line programs to run using the OS shell.
60-
# 📚 https://git.io/JvXDl
61-
62-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63-
# and modify them (or add more) to build your code if your project
64-
# uses a compiled language
65-
66-
#- run: |
67-
# make bootstrap
68-
# make release
69-
7046
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v3
47+
id: analyze
48+
uses: github/codeql-action/analyze@v3

.github/workflows/licensed.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# This workflow checks the statuses of cached dependencies used in this action
2+
# with the help of the Licensed tool. If any licenses are invalid or missing,
3+
# this workflow will fail. See: https://github.com/licensee/licensed
4+
5+
name: Licensed
6+
7+
on:
8+
# Uncomment the below lines to run this workflow on pull requests and pushes
9+
# to the default branch. This is useful for checking licenses before merging
10+
# changes into the default branch.
11+
# pull_request:
12+
# branches:
13+
# - main
14+
# push:
15+
# branches:
16+
# - main
17+
workflow_dispatch:
18+
19+
permissions:
20+
contents: write
21+
22+
jobs:
23+
licensed:
24+
name: Check Licenses
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout
29+
id: checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Setup Node.js
33+
id: setup-node
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version-file: .node-version
37+
cache: npm
38+
39+
- name: Install Dependencies
40+
id: npm-ci
41+
run: npm ci
42+
43+
- name: Setup Ruby
44+
id: setup-ruby
45+
uses: ruby/setup-ruby@v1
46+
with:
47+
ruby-version: ruby
48+
49+
- uses: licensee/setup-licensed@v1.3.2
50+
with:
51+
version: 4.x
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
54+
# If this is a workflow_dispatch event, update the cached licenses.
55+
- if: ${{ github.event_name == 'workflow_dispatch' }}
56+
name: Update Licenses
57+
id: update-licenses
58+
run: licensed cache
59+
60+
# Then, commit the updated licenses to the repository.
61+
- if: ${{ github.event_name == 'workflow_dispatch' }}
62+
name: Commit Licenses
63+
id: commit-licenses
64+
run: |
65+
git config --local user.email "licensed-ci@users.noreply.github.com"
66+
git config --local user.name "licensed-ci"
67+
git add .
68+
git commit -m "Auto-update license files"
69+
git push
70+
71+
# Last, check the status of the cached licenses.
72+
- name: Check Licenses
73+
id: check-licenses
74+
run: licensed status

.github/workflows/linter.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Lint Codebase
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
packages: read
14+
statuses: write
15+
16+
jobs:
17+
lint:
18+
name: Lint Codebase
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout
23+
id: checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup Node.js
29+
id: setup-node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version-file: .node-version
33+
cache: npm
34+
35+
- name: Install Dependencies
36+
id: install
37+
run: npm ci
38+
39+
- name: Lint Codebase
40+
id: super-linter
41+
uses: super-linter/super-linter/slim@v7
42+
env:
43+
DEFAULT_BRANCH: main
44+
FILTER_REGEX_EXCLUDE: dist/**/*
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
LINTER_RULES_PATH: ${{ github.workspace }}
47+
VALIDATE_ALL_CODEBASE: true
48+
VALIDATE_JAVASCRIPT_ES: false
49+
VALIDATE_JAVASCRIPT_STANDARD: false
50+
VALIDATE_JSCPD: false
51+
VALIDATE_TYPESCRIPT_ES: false
52+
VALIDATE_JSON: false
53+
VALIDATE_TYPESCRIPT_STANDARD: false

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 20.9.0

0 commit comments

Comments
 (0)