Skip to content

Commit 08467d7

Browse files
committed
feat: initial commit
0 parents  commit 08467d7

31 files changed

+110304
-0
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lib/
2+
dist/
3+
node_modules/
4+
coverage/

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto eol=lf
2+
3+
dist/** -diff linguist-generated=true

.github/linters/.eslintrc.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
env:
2+
node: true
3+
es6: true
4+
jest: true
5+
6+
globals:
7+
Atomics: readonly
8+
SharedArrayBuffer: readonly
9+
10+
ignorePatterns:
11+
- '!.*'
12+
- '**/node_modules/.*'
13+
- '**/dist/.*'
14+
- '**/coverage/.*'
15+
- '*.json'
16+
17+
parser: '@typescript-eslint/parser'
18+
19+
parserOptions:
20+
ecmaVersion: 2023
21+
sourceType: module
22+
project:
23+
- './.github/linters/tsconfig.json'
24+
- './tsconfig.json'
25+
26+
plugins:
27+
- jest
28+
- '@typescript-eslint'
29+
30+
extends:
31+
- eslint:recommended
32+
- plugin:@typescript-eslint/eslint-recommended
33+
- plugin:@typescript-eslint/recommended
34+
- plugin:github/recommended
35+
- plugin:jest/recommended
36+
37+
rules:
38+
{
39+
'camelcase': 'off',
40+
'eslint-comments/no-use': 'off',
41+
'eslint-comments/no-unused-disable': 'off',
42+
'i18n-text/no-en': 'off',
43+
'import/no-namespace': 'off',
44+
'no-console': 'off',
45+
'no-unused-vars': 'off',
46+
'prettier/prettier': 'error',
47+
'semi': 'off',
48+
'@typescript-eslint/array-type': 'error',
49+
'@typescript-eslint/await-thenable': 'error',
50+
'@typescript-eslint/ban-ts-comment': 'error',
51+
'@typescript-eslint/consistent-type-assertions': 'error',
52+
'@typescript-eslint/explicit-member-accessibility':
53+
['error', { 'accessibility': 'no-public' }],
54+
'@typescript-eslint/explicit-function-return-type':
55+
['error', { 'allowExpressions': true }],
56+
'@typescript-eslint/func-call-spacing': ['error', 'never'],
57+
'@typescript-eslint/no-array-constructor': 'error',
58+
'@typescript-eslint/no-empty-interface': 'error',
59+
'@typescript-eslint/no-explicit-any': 'error',
60+
'@typescript-eslint/no-extraneous-class': 'error',
61+
'@typescript-eslint/no-for-in-array': 'error',
62+
'@typescript-eslint/no-inferrable-types': 'error',
63+
'@typescript-eslint/no-misused-new': 'error',
64+
'@typescript-eslint/no-namespace': 'error',
65+
'@typescript-eslint/no-non-null-assertion': 'warn',
66+
'@typescript-eslint/no-require-imports': 'error',
67+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
68+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
69+
'@typescript-eslint/no-unused-vars': 'error',
70+
'@typescript-eslint/no-useless-constructor': 'error',
71+
'@typescript-eslint/no-var-requires': 'error',
72+
'@typescript-eslint/prefer-for-of': 'warn',
73+
'@typescript-eslint/prefer-function-type': 'warn',
74+
'@typescript-eslint/prefer-includes': 'error',
75+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
76+
'@typescript-eslint/promise-function-async': 'error',
77+
'@typescript-eslint/require-array-sort-compare': 'error',
78+
'@typescript-eslint/restrict-plus-operands': 'error',
79+
'@typescript-eslint/semi': 'error',
80+
'@typescript-eslint/space-before-function-paren': 'off',
81+
'@typescript-eslint/type-annotation-spacing': 'error',
82+
'@typescript-eslint/unbound-method': 'error'
83+
}

.github/linters/.markdown-lint.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Unordered list style
2+
MD004:
3+
style: dash
4+
5+
# Ordered list item prefix
6+
MD029:
7+
style: one

.github/linters/.yaml-lint.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
rules:
2+
document-end: disable
3+
document-start:
4+
level: warning
5+
present: false
6+
line-length:
7+
level: warning
8+
max: 80
9+
allow-non-breakable-words: true
10+
allow-non-breakable-inline-mappings: true

.github/linters/tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"extends": "../../tsconfig.json",
4+
"compilerOptions": {
5+
"noEmit": true
6+
},
7+
"include": ["../../__tests__/**/*", "../../src/**/*"],
8+
"exclude": ["../../dist", "../../node_modules", "../../coverage", "*.json"]
9+
}

.github/workflows/check-dist.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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
11+
12+
on:
13+
push:
14+
branches:
15+
- main
16+
pull_request:
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
check-dist:
23+
name: Check dist/
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout
28+
id: checkout
29+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
30+
31+
- name: Setup Node.js
32+
id: setup-node
33+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
34+
with:
35+
node-version: 20
36+
cache: npm
37+
38+
- name: Install Dependencies
39+
id: install
40+
run: npm ci
41+
42+
- name: Build dist/ Directory
43+
id: build
44+
run: npm run bundle
45+
46+
# This will fail the workflow if the PR wasn't created by Dependabot.
47+
- name: Compare Directories
48+
id: diff
49+
run: |
50+
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
51+
echo "Detected uncommitted changes after build. See status below:"
52+
git diff --ignore-space-at-eol --text dist/
53+
exit 1
54+
fi
55+
56+
# If `dist/` was different than expected, and this was not a Dependabot
57+
# PR, upload the expected version as a workflow artifact.
58+
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
59+
name: Upload Artifact
60+
id: upload
61+
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
62+
with:
63+
name: dist
64+
path: dist/

.github/workflows/ci.yml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Continuous Integration
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test-typescript:
14+
name: TypeScript Tests
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
19+
- name: Setup Node.js
20+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
21+
with:
22+
node-version: 20
23+
cache: npm
24+
- name: Install Dependencies
25+
run: npm ci
26+
- name: Check Format
27+
run: npm run format:check
28+
- name: Lint
29+
run: npm run lint
30+
- name: Test
31+
run: npm run ci-test
32+
33+
test-action:
34+
name: GitHub Actions Test
35+
runs-on: ubuntu-latest
36+
needs: test-typescript
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
40+
- name: Test Local Action (Single File Valid)
41+
id: single-file-valid
42+
uses: ./
43+
with:
44+
schema: https://json.schemastore.org/github-workflow.json
45+
files: .github/workflows/ci.yml
46+
- name: Test Local Action (Single File Not Valid)
47+
id: single-file-not-valid
48+
uses: ./
49+
with:
50+
# Use the wrong schema so it fails validation
51+
schema: https://gist.githubusercontent.com/dsanders11/b17fd12c00fc44b487df66d61039398e/raw/f05a9c19d6662282b1576b268e5c3228befc4700/schema.json
52+
files: .github/workflows/ci.yml
53+
fail-on-invalid: false
54+
- name: Test Local Action (Multiple File Valid)
55+
id: multiple-file-valid
56+
uses: ./
57+
with:
58+
schema: https://json.schemastore.org/github-workflow.json
59+
files: .github/workflows/**.yml
60+
- name: Test Local Action (Multiple File Not Valid)
61+
id: multiple-file-not-valid
62+
uses: ./
63+
with:
64+
# Use the wrong schema so it fails validation
65+
schema: https://gist.githubusercontent.com/dsanders11/b17fd12c00fc44b487df66d61039398e/raw/f05a9c19d6662282b1576b268e5c3228befc4700/schema.json
66+
files: .github/workflows/**.yml
67+
fail-on-invalid: false
68+
- name: Confirm Output
69+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
70+
with:
71+
script: |
72+
const assert = require('node:assert');
73+
74+
assert.strictEqual(${{ steps.single-file-valid.outputs.valid }}, true, 'Expected output for single file valid to be true');
75+
assert.strictEqual(${{ steps.single-file-not-valid.outputs.valid }}, false, 'Expected output for single file invalid to be false');
76+
assert.strictEqual(${{ steps.multiple-file-valid.outputs.valid }}, true, 'Expected output for multiple file valid to be true');
77+
assert.strictEqual(${{ steps.multiple-file-not-valid.outputs.valid }}, false, 'Expected output for multiple file invalid to be false');
78+
79+
release:
80+
name: release
81+
runs-on: ubuntu-latest
82+
needs: test-action
83+
if: github.ref == 'refs/heads/main'
84+
permissions:
85+
contents: write
86+
steps:
87+
- name: Checkout
88+
id: checkout
89+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
90+
- run: npx semantic-release
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/codeql-analysis.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
schedule:
11+
- cron: '31 7 * * 3'
12+
13+
jobs:
14+
analyze:
15+
name: Analyze
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
actions: read
20+
checks: write
21+
contents: read
22+
security-events: write
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
language:
28+
- TypeScript
29+
30+
steps:
31+
- name: Checkout
32+
id: checkout
33+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
34+
35+
- name: Initialize CodeQL
36+
id: initialize
37+
uses: github/codeql-action/init@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12
38+
with:
39+
languages: ${{ matrix.language }}
40+
source-root: src
41+
42+
- name: Autobuild
43+
id: autobuild
44+
uses: github/codeql-action/autobuild@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12
45+
46+
- name: Perform CodeQL Analysis
47+
id: analyze
48+
uses: github/codeql-action/analyze@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12

.github/workflows/linter.yml

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

0 commit comments

Comments
 (0)