Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix workflows with health #48

Merged
merged 3 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# don't ever lint node_modules
node_modules
# don't lint build output (make sure it's set to your correct build folder name)
dist
# don't lint nyc coverage output
coverage
# don't lint the packages
packages
# don't line the docs
docs
.eslintrc.js
25 changes: 21 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,43 @@ module.exports = {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
plugins: ['@typescript-eslint/eslint-plugin', 'jest', 'prettier'],
extends: [
'plugin:@typescript-eslint/recommended',
'eslint:recommended',
'plugin:prettier/recommended',
'prettier',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'no-unused-vars': 'off',
'no-constant-condition': 'off',
'no-useless-escape': 'off',
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],
},
overrides: [
{
files: ['*.spec.js'],
plugins: ['jest'],
extends: ['plugin:jest/recommended'],
rules: {
'jest/prefer-expect-assertions': 0,
},
},
],
}
65 changes: 65 additions & 0 deletions .github/workflows/health-check/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: '☑️ Checks Pipeline'
description: 'Checks the codebase health'

inputs:
run-tests-command:
description: 'Run tests command, default is `npm test`'
default: 'npm test'
required: false

run-tests:
description: 'Run tests'
default: 'true'
required: false

run-lint-command:
description: 'Run linter command, default is `npm run lint`'
default: 'npm run lint'
required: false

run-lint:
description: 'Run lint'
default: 'true'
required: false

run-build-command:
description: 'Run build command, default is `npm run build`'
default: 'npm run build'
required: false

run-build:
description: 'Run build'
default: 'true'
required: false

runs:
using: composite
steps:
- name: 🖥️ Setup Node
uses: actions/setup-node@v3
with:
node-version: 16

- name: 🔗 Install Dependencies
shell: bash
run: |
npm install --legacy-peer-deps

- name: 🧪 Test
if: ${{ inputs.run-tests == 'true' }}
shell: bash
run: |
${{ inputs.run-tests-command }}

- name: 🔨 Build
if: ${{ inputs.run-build == 'true' }}
shell: bash
run: |
${{ inputs.run-build-command }}

- name: ✅ Lint
if: ${{ inputs.run-lint == 'true' }}
shell: bash
run: |
${{ inputs.run-lint-command }}
20 changes: 20 additions & 0 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: PR Health Checks 🐛
on:
pull_request:
branches:
- master

jobs:
PR-checks:
# https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/using-self-hosted-runners-in-a-workflow
runs-on: ubuntu-latest
name: PR Health Checks 🐛
steps:
- name: 📀 Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: 🧪 Check out repository code
uses: ./.github/workflows/health-check
34 changes: 28 additions & 6 deletions .github/workflows/release-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ on:
push:
branches:
- master
# pull_request:
# types: [closed]
# branches:
# - master

permissions:
contents: write
Expand All @@ -14,12 +10,38 @@ permissions:
name: 📦 Create New Release

jobs:
release:
checks:
name: ✅ Check for Release
runs-on: ubuntu-latest
timeout-minutes: 15

env:
HUSKY: 0

steps:
- name: 📀 Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: 🧪 Check out repository code
uses: ./.github/workflows/health-check

release:
name: 📦 Release Version
runs-on: ubuntu-latest
timeout-minutes: 60
needs:
- checks

env:
HUSKY: 0

steps:
- name: 📀 Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: 🗃️ Install Node.js Deps
run: |
Expand Down
30 changes: 28 additions & 2 deletions .github/workflows/release-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,38 @@ permissions:
name: 📦 Create New Beta Release

jobs:
release:
checks:
name: ✅ Check for Release
runs-on: ubuntu-latest
timeout-minutes: 15

env:
HUSKY: 0

steps:
- name: 📀 Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: 🧪 Check out repository code
uses: ./.github/workflows/health-check

release:
name: 📦 Release Beta Version
runs-on: ubuntu-latest
timeout-minutes: 60
needs:
- checks

env:
HUSKY: 0

steps:
- name: 📀 Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: 🗃️ Install Node.js Deps
run: |
Expand Down
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
"pack": "./project-scripts/pack.sh",
"pack-local": "./project-scripts/pack-local.sh",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"start": "node dist/main.js",
"start:dev": "ts-node src/main.ts",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"create-fig-spec": "./project-scripts/create-fig-spec.sh",
"publish-fig-spec": "./project-scripts/publish-fig-spec.sh",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
Expand Down Expand Up @@ -59,6 +60,7 @@
"@typescript-eslint/parser": "^5.59.11",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-jest": "^27.6.1",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"jest": "^29.5.0",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/external/external.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ExternalCommand extends CommandRunner {
super()
}

async run(inputs: string[], options: Record<string, any>): Promise<void> {
async run(inputs: string[], options: Record<string, unknown>): Promise<void> {
await this.checkUpdateService.checkForUpdates()

return this.command.help()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/external/sub-commands/delete.sub-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class DeleteSubCommand extends CommandRunner {
this.logger.setContext(DeleteSubCommand.name)
}

async run(inputs: string[], options: Record<string, any>): Promise<void> {
async run(inputs: string[], options: Record<string, unknown>): Promise<void> {
await this.checkUpdateService.checkForUpdates()

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import type { TestingModule } from '@nestjs/testing'
import { Test } from '@nestjs/testing'
import { CheckUpdateService } from '@services/check-update.service'
Expand Down Expand Up @@ -40,7 +41,7 @@ describe('InstallSubCommand', () => {
])(
'should grab the name of the external with the extension of .sh',
({ input, expRes }) => {
// @ts-ignore
// @ts-expect-error
const res = service.parseExternalName(input)
expect(res).toEqual(expRes)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class InstallSubCommand extends CommandRunner {
this.logger.setContext(InstallSubCommand.name)
}

async run(inputs: string[], options: Record<string, any>): Promise<void> {
async run(inputs: string[], options: Record<string, unknown>): Promise<void> {
await this.checkUpdateService.checkForUpdates()

try {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/external/sub-commands/list.sub-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class ListSubCommand extends CommandRunner {
this.logger.setContext(ListSubCommand.name)
}

async run(inputs: string[], options: Record<string, any>): Promise<void> {
async run(inputs: string[], options: Record<string, unknown>): Promise<void> {
await this.checkUpdateService.checkForUpdates()

try {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/init-script/init-script.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ export class InitScriptCommand extends CommandRunner {
super()
}

async run(inputs: string[], options: Record<string, any>): Promise<void> {
async run(inputs: string[], options: Record<string, unknown>): Promise<void> {
try {
const hasPermissions: boolean = await access(`${BASE_PATH}/zsh`)
.then(() => true)
.catch(() => false)

const script = hasPermissions ? INIT_DYNAMIC_SCRIPT : OPEN_TERMINAL
console.log(script)
// eslint-disable-next-line no-empty
} catch (error) {}
}
}
2 changes: 1 addition & 1 deletion src/commands/init/init.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class InitCommand extends CommandRunner {
this.logger.setContext(InitCommand.name)
}

async run(inputs: string[], options: Record<string, any>): Promise<void> {
async run(inputs: string[], options: Record<string, unknown>): Promise<void> {
await this.checkUpdateService.checkForUpdates()

try {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/install/install.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class InstallCommand extends CommandRunner {
this.logger.setContext(InstallCommand.name)
}

async run(inputs: string[], options: Record<string, any>): Promise<void> {
async run(inputs: string[], options: Record<string, unknown>): Promise<void> {
await this.checkUpdateService.checkForUpdates()

try {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/shell/shell.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ShellCommand extends CommandRunner {
this.logger.setContext(ShellCommand.name)
}

async run(inputs: string[], options: Record<string, any>): Promise<void> {
async run(inputs: string[], options: Record<string, unknown>): Promise<void> {
await this.checkUpdateService.checkForUpdates()

try {
Expand Down
Loading