forked from skunight/nestjs-redis
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from useparagon/feat/add-whiskers
added whiskers for ci
- Loading branch information
Showing
13 changed files
with
884 additions
and
10 deletions.
There are no files selected for viewing
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,104 @@ | ||
## --------------------------------------------------- | ||
## |\---/| | ||
## | ,_, | !! DO NOT MODIFY !! | ||
## \_`_/-..----. file managed by `whiskers` | ||
## ___/ ` ' ,""+ \ | ||
## (__...' __\ |`.___.'; | ||
## (_,...'(_,.`__)/'.....+ | ||
## --------------------------------------------------- | ||
|
||
name: build | ||
|
||
on: | ||
pull_request: {} | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
name: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: git > checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 | ||
with: | ||
clean: true | ||
fetch-depth: 1 | ||
|
||
- name: node > setup | ||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 | ||
with: | ||
node-version-file: .nvmrc | ||
cache: yarn | ||
|
||
- name: yarn > install | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: yarn > build | ||
env: | ||
NODE_ENV: production | ||
run: yarn build | ||
|
||
- name: ci > upload artifacts | ||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 | ||
with: | ||
name: dist | ||
path: dist/ | ||
if-no-files-found: error | ||
lint: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: git > checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 | ||
with: | ||
clean: true | ||
fetch-depth: 1 | ||
|
||
- name: node > setup | ||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 | ||
with: | ||
node-version-file: .nvmrc | ||
cache: yarn | ||
|
||
- name: yarn > install | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: yarn > lint | ||
run: yarn lint | ||
verify_workflow: | ||
name: verify workflow | ||
runs-on: ubuntu-latest | ||
if: always() | ||
needs: | ||
- build | ||
- lint | ||
steps: | ||
|
||
- name: verify workflow success | ||
if: always() | ||
run: |- | ||
# resolve statuses | ||
BUILD_AGGREGATE=(${{ needs['build'].result }}) | ||
BUILD=unknown | ||
BUILD=$(if [[ " ${BUILD_AGGREGATE[@]} " == *"success"* ]]; then echo "success"; else echo "$BUILD"; fi) | ||
BUILD=$(if [[ " ${BUILD_AGGREGATE[@]} " == *"skipped"* ]]; then echo "skipped"; else echo "$BUILD"; fi) | ||
BUILD=$(if [[ " ${BUILD_AGGREGATE[@]} " == *"cancelled"* ]]; then echo "cancelled"; else echo "$BUILD"; fi) | ||
BUILD=$(if [[ " ${BUILD_AGGREGATE[@]} " == *"failure"* ]]; then echo "failure"; else echo "$BUILD"; fi) | ||
LINT_AGGREGATE=(${{ needs['lint'].result }}) | ||
LINT=unknown | ||
LINT=$(if [[ " ${LINT_AGGREGATE[@]} " == *"success"* ]]; then echo "success"; else echo "$LINT"; fi) | ||
LINT=$(if [[ " ${LINT_AGGREGATE[@]} " == *"skipped"* ]]; then echo "skipped"; else echo "$LINT"; fi) | ||
LINT=$(if [[ " ${LINT_AGGREGATE[@]} " == *"cancelled"* ]]; then echo "cancelled"; else echo "$LINT"; fi) | ||
LINT=$(if [[ " ${LINT_AGGREGATE[@]} " == *"failure"* ]]; then echo "failure"; else echo "$LINT"; fi) | ||
# echo the results of each job | ||
echo "BUILD: $BUILD" | ||
echo "LINT: $LINT" | ||
# assert success | ||
if [[ "$BUILD" != "success" ]]; then exit 1; fi | ||
if [[ "$LINT" != "success" ]]; then exit 1; fi |
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,106 @@ | ||
## --------------------------------------------------- | ||
## |\---/| | ||
## | ,_, | !! DO NOT MODIFY !! | ||
## \_`_/-..----. file managed by `whiskers` | ||
## ___/ ` ' ,""+ \ | ||
## (__...' __\ |`.___.'; | ||
## (_,...'(_,.`__)/'.....+ | ||
## --------------------------------------------------- | ||
|
||
name: publish | ||
run-name: publish v${{ inputs.version }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: The branch of the build. Used to find artifacts and tag. | ||
required: true | ||
release_type: | ||
description: The type of release. | ||
required: true | ||
type: choice | ||
options: | ||
- experimental | ||
- stable | ||
default: experimental | ||
version: | ||
description: "The version of this release. Omit 'v' prefix. Example: '1.0.1-experimental.1'." | ||
required: true | ||
|
||
jobs: | ||
version_bump: | ||
name: version bump | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
|
||
- name: git > checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 | ||
with: | ||
clean: true | ||
fetch-depth: 1 | ||
token: ${{ secrets.BOT_GITHUB_TOKEN }} | ||
ref: ${{ inputs.branch }} | ||
|
||
- name: node > setup | ||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 | ||
with: | ||
node-version-file: .nvmrc | ||
cache: yarn | ||
|
||
- name: yarn > install | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: yarn > bump version | ||
run: yarn run release:version:bump ${{ inputs.version }} | ||
|
||
- name: git > commit version bump | ||
uses: EndBug/add-and-commit@1bad3abcf0d6ec49a5857d124b0bfb52dc7bb081 | ||
with: | ||
default_author: github_actions | ||
message: bump version to ${{ inputs.version }} | ||
push: true | ||
tag: v${{ inputs.version }} | ||
publish: | ||
name: publish | ||
runs-on: ubuntu-latest | ||
needs: | ||
- version_bump | ||
steps: | ||
|
||
- name: git > checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 | ||
with: | ||
clean: true | ||
fetch-depth: 1 | ||
token: ${{ secrets.BOT_GITHUB_TOKEN }} | ||
ref: v${{ inputs.version }} | ||
|
||
- name: node > setup | ||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 | ||
with: | ||
node-version-file: .nvmrc | ||
cache: yarn | ||
|
||
- name: yarn > install | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: ci > download artifacts | ||
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e | ||
with: | ||
workflow: build.yaml | ||
workflow_conclusion: success | ||
branch: ${{ inputs.branch }} | ||
|
||
- name: yarn > publish (experimental) | ||
if: inputs.release_type == 'experimental' | ||
env: | ||
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: yarn run release:publish:experimental | ||
|
||
- name: yarn > publish (stable) | ||
if: inputs.release_type == 'stable' | ||
env: | ||
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: yarn run release:publish:stable |
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,36 @@ | ||
## --------------------------------------------------- | ||
## |\---/| | ||
## | ,_, | !! DO NOT MODIFY !! | ||
## \_`_/-..----. file managed by `whiskers` | ||
## ___/ ` ' ,""+ \ | ||
## (__...' __\ |`.___.'; | ||
## (_,...'(_,.`__)/'.....+ | ||
## --------------------------------------------------- | ||
|
||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v*.*.* | ||
|
||
jobs: | ||
release: | ||
name: release | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
|
||
- name: git > checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 | ||
with: | ||
clean: true | ||
fetch-depth: 1 | ||
token: ${{ secrets.BOT_GITHUB_TOKEN }} | ||
|
||
- name: release > create github release | ||
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 | ||
with: | ||
token: ${{ secrets.BOT_GITHUB_TOKEN }} | ||
generate_release_notes: true | ||
prerelease: ${{ contains(github.ref, 'experimental') }} |
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 @@ | ||
v18.17.1 |
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,23 @@ | ||
import { CheckoutParams, GitCheckoutWorkflowStep } from '@useparagon/whiskers-cattery-git'; | ||
import { SetupNodeWorkflowStep } from '@useparagon/whiskers-cattery-node'; | ||
import { GithubActionWorkflowStep, ShellStepConfig } from '@useparagon/whiskers-core'; | ||
|
||
export function setupSteps(params: CheckoutParams = {}): GithubActionWorkflowStep<any>[] { | ||
return [ | ||
new GitCheckoutWorkflowStep({ | ||
name: 'git > checkout', | ||
with: params, | ||
}), | ||
new SetupNodeWorkflowStep({ | ||
name: 'node > setup', | ||
with: { | ||
'node-version-file': '.nvmrc', | ||
cache: 'yarn', | ||
}, | ||
}), | ||
new GithubActionWorkflowStep<ShellStepConfig>({ | ||
name: 'yarn > install', | ||
run: 'yarn install --frozen-lockfile', | ||
}), | ||
]; | ||
} |
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,4 @@ | ||
export enum ReleaseTypes { | ||
experimental = 'experimental', | ||
stable = 'stable', | ||
} |
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,16 @@ | ||
import { prefixSuffixEnumValues } from '@useparagon/whiskers-core'; | ||
|
||
export enum SecretKeys { | ||
/** | ||
* Personal access token for the GitHub bot to use for interactions with | ||
* GitHub. | ||
*/ | ||
BOT_GITHUB_TOKEN = 'BOT_GITHUB_TOKEN', | ||
|
||
/** | ||
* npm auth token for the npm registry. | ||
*/ | ||
NPM_TOKEN = 'NPM_TOKEN', | ||
} | ||
|
||
export const Secrets = prefixSuffixEnumValues('secrets.', SecretKeys, ''); |
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,63 @@ | ||
import { | ||
GithubActionWorkflow, | ||
GithubActionWorkflowJob, | ||
GithubActionWorkflowStep, | ||
ActionsStepConfig, | ||
ShellStepConfig, | ||
} from '@useparagon/whiskers-core'; | ||
import { VerifyWorkflowSuccessGithubActionWorkflowJob } from '@useparagon/whiskers-cattery-github'; | ||
|
||
import { setupSteps } from '../steps/setup'; | ||
|
||
const JOB_ID_BUILD = 'build'; | ||
const JOB_ID_LINT = 'lint'; | ||
|
||
export default new GithubActionWorkflow({ | ||
name: 'build', | ||
on: { | ||
pull_request: {}, | ||
push: { | ||
branches: ['master'], | ||
}, | ||
}, | ||
jobs: [ | ||
new GithubActionWorkflowJob({ | ||
id: JOB_ID_BUILD, | ||
name: 'build', | ||
steps: [ | ||
...setupSteps(), | ||
new GithubActionWorkflowStep<ShellStepConfig>({ | ||
name: 'yarn > build', | ||
run: 'yarn build', | ||
env: { | ||
NODE_ENV: 'production', | ||
}, | ||
}), | ||
new GithubActionWorkflowStep<ActionsStepConfig<any>>({ | ||
name: 'ci > upload artifacts', | ||
uses: 'actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32', // v3.1.3 | ||
with: { | ||
name: 'dist', | ||
path: 'dist/', | ||
'if-no-files-found': 'error', | ||
}, | ||
}), | ||
], | ||
}), | ||
new GithubActionWorkflowJob({ | ||
id: JOB_ID_LINT, | ||
name: 'lint', | ||
steps: [ | ||
...setupSteps(), | ||
new GithubActionWorkflowStep({ | ||
name: 'yarn > lint', | ||
run: 'yarn lint', | ||
}), | ||
], | ||
}), | ||
new VerifyWorkflowSuccessGithubActionWorkflowJob({ | ||
BUILD: JOB_ID_BUILD, | ||
LINT: JOB_ID_LINT, | ||
}), | ||
], | ||
}); |
Oops, something went wrong.