generated from MatrixAI/TypeScript-Demo-Lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: attempting to use centralized CI in
MatrixAI/.github
- Loading branch information
1 parent
ff2437f
commit afd4683
Showing
6 changed files
with
147 additions
and
225 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: "CI / Feature" | ||
|
||
on: | ||
push: | ||
branches: | ||
- feature* | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
use-library-js-feature: | ||
permissions: | ||
packages: read | ||
contents: read | ||
actions: write | ||
checks: write | ||
uses: MatrixAI/.github/.github/workflows/library-js-feature.yml@feature-workflows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "CI / Staging" | ||
|
||
on: | ||
push: | ||
branches: | ||
- staging | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
use-library-js-staging: | ||
permissions: | ||
packages: read | ||
contents: read | ||
actions: write | ||
checks: write | ||
pull-requests: write | ||
uses: MatrixAI/.github/.github/workflows/library-js-staging.yml@feature-workflows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: "CI / Tag" | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
use-library-js-tag: | ||
permissions: | ||
packages: read | ||
contents: read | ||
actions: write | ||
uses: MatrixAI/.github/.github/workflows/library-js-tag.yml@feature-workflows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/env node | ||
|
||
import os from 'node:os'; | ||
import path from 'node:path'; | ||
import url from 'node:url'; | ||
import process from 'node:process'; | ||
import childProcess from 'node:child_process'; | ||
|
||
const projectPath = path.dirname( | ||
path.dirname(url.fileURLToPath(import.meta.url)), | ||
); | ||
|
||
const platform = os.platform(); | ||
|
||
/* eslint-disable no-console */ | ||
async function main(argv = process.argv) { | ||
argv = argv.slice(2); | ||
let fix = false; | ||
const restArgs = []; | ||
while (argv.length > 0) { | ||
const option = argv.shift(); | ||
if (option === '--fix') { | ||
fix = true; | ||
argv.shift(); | ||
} else { | ||
restArgs.push(option); | ||
} | ||
} | ||
// Linting code | ||
const eslintArgs = [ | ||
'{src,tests,scripts,benches}/**/*.{js,mjs,ts,mts,jsx,tsx,json}', | ||
]; | ||
if (fix) { | ||
eslintArgs.push('--fix'); | ||
} | ||
console.error('Running eslint:'); | ||
console.error(['eslint', ...eslintArgs].join(' ')); | ||
childProcess.execFileSync('eslint', eslintArgs, { | ||
stdio: ['inherit', 'inherit', 'inherit'], | ||
windowsHide: true, | ||
encoding: 'utf-8', | ||
shell: platform === 'win32' ? true : false, | ||
cwd: projectPath, | ||
}); | ||
// Linting shell scripts (this does not have auto-fixing) | ||
const shellCheckArgs = [ | ||
'./src', | ||
'./tests', | ||
'./scripts', | ||
'-type', | ||
'f', | ||
'-regextype', | ||
'posix-extended', | ||
'-regex', | ||
'.*\\.(sh)', | ||
'-exec', | ||
'shellcheck', | ||
'{}', | ||
'+', | ||
]; | ||
console.error('Running shellcheck:'); | ||
console.error(['find', ...shellCheckArgs].join(' ')); | ||
childProcess.execFileSync('find', shellCheckArgs, { | ||
stdio: ['inherit', 'inherit', 'inherit'], | ||
windowsHide: true, | ||
encoding: 'utf-8', | ||
shell: platform === 'win32' ? true : false, | ||
cwd: projectPath, | ||
}); | ||
// Linting markdown | ||
const prettierArgs = [!fix ? '--check' : '--write', './README.md']; | ||
console.error('Running prettier:'); | ||
console.error(['prettier', ...prettierArgs].join(' ')); | ||
childProcess.execFileSync('prettier', prettierArgs, { | ||
stdio: ['inherit', 'inherit', 'inherit'], | ||
windowsHide: true, | ||
encoding: 'utf-8', | ||
shell: platform === 'win32' ? true : false, | ||
cwd: projectPath, | ||
}); | ||
} | ||
/* eslint-enable no-console */ | ||
|
||
if (import.meta.url.startsWith('file:')) { | ||
const modulePath = url.fileURLToPath(import.meta.url); | ||
if (process.argv[1] === modulePath) { | ||
void main(); | ||
} | ||
} |