Skip to content

Commit

Permalink
ci(workflows): [ci] split ci job into multiple jobs
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Feb 12, 2023
1 parent 91df1e8 commit f7336ee
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ esbuild
esbuilder
evanw
fbca
ggshield
gpgsign
hmarr
iife
Expand All @@ -39,5 +40,4 @@ toodles
tribonacci
unstub
vates
vitest
yarnrc
230 changes: 222 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@
#
# References:
#
# - https://docs.github.com/actions/automating-builds-and-tests/building-and-testing-nodejs
# - https://docs.github.com/actions/learn-github-actions/contexts
# - https://docs.github.com/actions/learn-github-actions/expressions
# - https://docs.github.com/actions/using-jobs/using-a-matrix-for-your-jobs
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#pull_request
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#push
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
# - https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions
# - https://github.com/GitGuardian/ggshield-action
# - https://github.com/actions/cache
# - https://github.com/actions/cache/discussions/650
# - https://github.com/actions/checkout
# - https://github.com/actions/setup-node
# - https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#yarn2-configuration
# - https://github.com/hmarr/debug-action

---
Expand All @@ -17,23 +27,28 @@ on:
- feat/**
- hotfix/**
- main
- release/**
workflow_dispatch:
permissions:
packages: read
env:
CACHE_PATH: node_modules
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HUSKY: 0
REF: ${{ github.head_ref || github.ref_name }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
ci:
metadata:
if: |
github.event_name == 'pull_request' ||
github.event_name == 'workflow_dispatch' ||
!startsWith(github.event.head_commit.message, 'release:')
github.event.head_commit.author.name != 'dependabot[bot]'
&& github.event.head_commit.author.username != 'flexdevelopment'
&& !startsWith(github.event.head_commit.message, 'release:')
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.result }}
version-typescript: ${{ steps.version-typescript.outputs.result }}
steps:
- id: debug
name: Print environment variables and event payload
Expand All @@ -43,28 +58,227 @@ jobs:
uses: actions/checkout@v3.2.0
with:
ref: ${{ env.REF }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v3.6.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: yarn
name: Install dependencies
run: yarn ${{ github.actor == 'dependabot[bot]' && '' || '--no-immutable' }}
run: yarn ${{ github.actor == 'dependabot[bot]' && '--no-immutable' || '--immutable' }}
- id: cache
name: Cache dependencies
uses: actions/cache@v3.2.4
with:
key: ${{ runner.os }}-${{ github.run_id }}
path: ${{ env.CACHE_PATH }}
- id: version
name: Get package version
run: echo "result=$(jq .version package.json -r)" >> $GITHUB_OUTPUT
- id: version-typescript
name: Get TypeScript version
run: echo "result=$(jq .devDependencies.typescript package.json -r)" >> $GITHUB_OUTPUT
gitguardian:
needs: metadata
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout ${{ env.REF }}
uses: actions/checkout@v3.2.0
with:
fetch-depth: 0
ref: ${{ env.REF }}
- id: scan
name: Scan commits for secrets and policy breaches
uses: GitGuardian/ggshield-action@master
with:
args: --all-policies --show-secrets --verbose
env:
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GITHUB_PULL_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_PUSH_BASE_SHA: ${{ github.event.base }}
GITHUB_PUSH_BEFORE_SHA: ${{ github.event.before }}
format:
needs: metadata
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout ${{ env.REF }}
uses: actions/checkout@v3.2.0
with:
ref: ${{ env.REF }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v3.6.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: cache
name: Restore dependencies cache
uses: actions/cache@v3.2.4
with:
key: ${{ runner.os }}-${{ github.run_id }}
path: ${{ env.CACHE_PATH }}
- id: format
name: Check code formatting
run: yarn check:format
lint:
needs: metadata
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout ${{ env.REF }}
uses: actions/checkout@v3.2.0
with:
ref: ${{ env.REF }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v3.6.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: cache
name: Restore dependencies cache
uses: actions/cache@v3.2.4
with:
key: ${{ runner.os }}-${{ github.run_id }}
path: ${{ env.CACHE_PATH }}
- id: lint
name: Check lint status
run: yarn check:lint
spelling:
needs: metadata
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout ${{ env.REF }}
uses: actions/checkout@v3.2.0
with:
ref: ${{ env.REF }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v3.6.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: cache
name: Restore dependencies cache
uses: actions/cache@v3.2.4
with:
key: ${{ runner.os }}-${{ github.run_id }}
path: ${{ env.CACHE_PATH }}
- id: spelling
name: Check spelling
run: yarn check:spelling
typescript:
needs: metadata
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
typescript-version:
- ${{ needs.metadata.outputs.version-typescript }}
- latest
- ~4.9.0
- ~4.8.0
steps:
- id: checkout
name: Checkout ${{ env.REF }}
uses: actions/checkout@v3.2.0
with:
ref: ${{ env.REF }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v3.6.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: cache
name: Restore dependencies cache
uses: actions/cache@v3.2.4
with:
key: ${{ runner.os }}-${{ github.run_id }}
path: ${{ env.CACHE_PATH }}
- id: typescript
name: Install typescript@${{ matrix.typescript-version }}
run: yarn add -D typescript@${{ matrix.typescript-version }}
- id: typecheck
name: Run typecheck
run: yarn typecheck
test:
needs: metadata
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- 19
- 18
- 16
- 14
steps:
- id: checkout
name: Checkout ${{ env.REF }}
uses: actions/checkout@v3.2.0
with:
ref: ${{ env.REF }}
- id: node
name: Setup Node.js v${{ matrix.node-version }}
uses: actions/setup-node@v3.6.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version: ${{ matrix.node-version }}
- id: cache
name: Restore dependencies cache
uses: actions/cache@v3.2.4
with:
key: ${{ runner.os }}-${{ github.run_id }}
path: ${{ env.CACHE_PATH }}
- id: test
name: Run tests
run: yarn test:cov
env:
VITEST_SEGFAULT_RETRY: 3
run: yarn test:cov --segfault-retry=3
build:
needs: metadata
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout ${{ env.REF }}
uses: actions/checkout@v3.2.0
with:
ref: ${{ env.REF }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v3.6.0
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: cache
name: Restore dependencies cache
uses: actions/cache@v3.2.4
with:
key: ${{ runner.os }}-${{ github.run_id }}
path: ${{ env.CACHE_PATH }}
- id: pack
name: Pack project
run: yarn pack -o %s-%v.tgz
env:
NODE_ENV: production
- id: typecheck
name: Run typecheck
run: yarn check:types:build
- id: archive
name: Archive production artifacts
uses: actions/upload-artifact@v3.1.2
with:
name: |
${{ format('@{0}-{1}-{2}', github.repository_owner, github.event.repository.name, needs.metadata.outputs.version) }}
path: '*.tgz'
10 changes: 10 additions & 0 deletions __tests__/ts/v4/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"noEmitOnError": true,
"skipLibCheck": false,
"target": "es2020"
},
"exclude": ["**/__mocks__", "**/__tests__"],
"extends": "./tsconfig.json",
"include": ["../../../dist/*", "../../../src/*"]
}
61 changes: 61 additions & 0 deletions __tests__/ts/v4/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"compilerOptions": {
"allowJs": true,
"allowUnreachableCode": false,
"alwaysStrict": false,
"baseUrl": "../../..",
"checkJs": false,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"exactOptionalPropertyTypes": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"importsNotUsedAsValues": "error",
"isolatedModules": true,
"lib": ["dom", "es2021"],
"module": "esnext",
"moduleResolution": "node",
"newLine": "lf",
"noEmit": true,
"noErrorTruncation": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"outDir": "../../../dist",
"paths": {
"#fixtures/*": ["__fixtures__/*"],
"#src": ["src/index"],
"#src/*": ["src/*"],
"#tests/*": ["__tests__/*"]
},
"preserveConstEnums": true,
"preserveSymlinks": true,
"pretty": true,
"resolveJsonModule": true,
"rootDir": "../../..",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"target": "esnext",
"useDefineForClassFields": true,
"useUnknownInCatchVariables": true
},
"exclude": ["**/coverage", "**/dist", "**/node_modules"],
"include": [
"**/**.cjs",
"**/**.mjs",
"**/**.mts",
"**/**.ts",
"**/.*.cjs",
"__fixtures__/**/*.cts",
"__fixtures__/**/*.js"
]
}
6 changes: 6 additions & 0 deletions __tests__/ts/v4/tsconfig.typecheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"target": "es2020"
},
"extends": "./tsconfig.json"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"check:lint": "eslint --exit-on-fatal-error --ext cjs,cts,gql,js,json,json5,jsonc,md,mjs,mts,ts,yml --max-warnings 0 .",
"check:spelling": "cspell lint --color --no-progress --relative $@ \"**\"",
"check:types": "tsc -p tsconfig.typecheck.json",
"check:types:build": "tsc -p tsconfig.build.json",
"check:types:build": "bash ./scripts/typecheck-build.sh",
"check:upgrades": "yarn upgrade-interactive",
"clean:build": "trash ./{dist,*.tgz}",
"clean:coverage": "trash ./coverage",
Expand Down
Loading

0 comments on commit f7336ee

Please sign in to comment.