-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(github): add github actions for ci (#1852)
* ci(github): migrate ci from circleci to github - [x] reimplement circleci workflows using github actions ci; * ci(cleanup): remove .npmrc after publishing packages - [x] add a cleanup command that removes .npmrc after publishing packages; * ci(github): revise github actions ci workflows - [x] clean up workflows, add comments to justify suggestions; - [x] implement a reusable workflow that might be used later, add explanatory comments; * Update .github/workflows/get-variables.yml Co-authored-by: Mark Whitfeld <[email protected]> * Update .github/workflows/pr-validation.yml Co-authored-by: Mark Whitfeld <[email protected]> * ci(premerge): upload premerge unit test coverage results to code climate * ci(dry): setup jobs with a reusable workflow, use matrix for scripts - [x] use a reusable workflow to setup all jobs; - [x] use a matrix strategy to parallelize scripts execution; * ci(logging): echo explanation of the 'find ... shred ...' command * ci(artifacts): check build artifacts workflow - [x] add a reusable workflow to check for build artifacts; * ci(setup): fix setup workflow - get node version from inputs * ci(artifacts): save app/integrations dists to workspace cache * ci(actions): convert reusable workflows to composite actions * ci(actions): fix composite actions * ci(actions): update comments in action configs * ci(docs): fix comments in composite actions * ci(syntax): fix yaml syntax errors * ci(checkout): checkout sources before calling the setup action * ci(inputs): fix the setup action inputs * ci(syntax): fix the setup action syntax * ci(test): test:types needs *-build, move it to integration-test * ci(cache): fix workspace cache paths * ci(cache): exclude node_modules in the integrations dir from cache * ci(cache): fix workspace cache, remove unneeded code * ci(cache): fix workspace cache - [x] all actions must required build so that cache is correct; * ci(actions): add composite actions to upload/download artifacts - [x] add two composite actions to upload/download integration test artifacts; * fix: bundlesize step order (release & trunk) Co-authored-by: Mark Whitfeld <[email protected]>
- Loading branch information
1 parent
a69f8cc
commit 327646e
Showing
7 changed files
with
650 additions
and
0 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,37 @@ | ||
# For more information see: | ||
# - https://docs.github.com/en/actions/creating-actions/creating-a-composite-action | ||
# - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputsoutput_id | ||
|
||
# The action can be referenced in workflows like: | ||
# - ngxs/store/.github/actions/check-build-artifacts@master | ||
# - ./.github/actions/check-build-artifacts | ||
|
||
name: check-build-artifacts | ||
description: Ensure the build artifact directories exist | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Check @ngxs build artifacts | ||
shell: bash | ||
run: | | ||
echo "Making sure the build artifact directories exist." | ||
[[ -d $DEVTOOLS_PLUG_ART ]] && echo "$DEVTOOLS_PLUG_ART $OK" || echo "$DEVTOOLS_PLUG_ART $FAILURE" exit 1 | ||
[[ -d $FORM_PLUG_ART ]] && echo "$FORM_PLUG_ART $OK" || echo "$DEVTOOLS_PLUG_ART $FAILURE" exit 1 | ||
[[ -d $HMR_PLUG_ART ]] && echo "$HMR_PLUG_ART $OK" || echo "$HMR_PLUG_ART $FAILURE" exit 1 | ||
[[ -d $LOGGER_PLUG_ART ]] && echo "$LOGGER_PLUG_ART $OK" || echo "$LOGGER_PLUG_ART $FAILURE" exit 1 | ||
[[ -d $ROUTER_PLUG_ART ]] && echo "$ROUTER_PLUG_ART $OK" || echo "$ROUTER_PLUG_ART $FAILURE" exit 1 | ||
[[ -d $STORAGE_PLUG_ART ]] && echo "$STORAGE_PLUG_ART $OK" || echo "$STORAGE_PLUG_ART $FAILURE" exit 1 | ||
[[ -d $STORE_ART ]] && echo "$STORE_ART $OK" || echo "$STORE_ART $FAILURE" exit 1 | ||
[[ -d $WEBSOCKET_PLUG_ART ]] && echo "$WEBSOCKET_PLUG_ART $OK" || echo "$WEBSOCKET_PLUG_ART $FAILURE" exit 1 | ||
env: | ||
OK: 'exists' | ||
FAILURE: 'does not exist' | ||
DEVTOOLS_PLUG_ART: './@ngxs/devtools-plugin' | ||
FORM_PLUG_ART: './@ngxs/form-plugin' | ||
HMR_PLUG_ART: './@ngxs/hmr-plugin' | ||
LOGGER_PLUG_ART: './@ngxs/logger-plugin' | ||
ROUTER_PLUG_ART: './@ngxs/router-plugin' | ||
STORAGE_PLUG_ART: './@ngxs/storage-plugin' | ||
STORE_ART: './@ngxs/store' | ||
WEBSOCKET_PLUG_ART: './@ngxs/websocket-plugin' |
43 changes: 43 additions & 0 deletions
43
.github/actions/download-integration-test-artifacts/action.yml
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,43 @@ | ||
# For more information see: | ||
# - https://docs.github.com/en/actions/creating-actions/creating-a-composite-action | ||
# - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputsoutput_id | ||
|
||
# The action can be referenced in workflows like: | ||
# - ngxs/store/.github/actions/download-integration-test-artifacts@master | ||
# - ./.github/actions/download-integration-test-artifacts | ||
|
||
name: download-integration-test-artifact | ||
description: Downloads all integration test artifacts with names such as 'hello-world-ng11-ivy'. | ||
|
||
inputs: | ||
path: | ||
description: A path to download the artifacts. | ||
required: true | ||
default: './integrations' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Download hello-world-ng11-ivy artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: hello-world-ng11-ivy | ||
path: ${{ inputs.path }} | ||
|
||
- name: Download hello-world-ng12-ivy artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: hello-world-ng12-ivy | ||
path: ${{ inputs.path }} | ||
|
||
- name: Download hello-world-ng13-ivy artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: hello-world-ng13-ivy | ||
path: ${{ inputs.path }} | ||
|
||
- name: Download hello-world-ng14-ivy artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: hello-world-ng14-ivy | ||
path: ${{ inputs.path }} |
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,66 @@ | ||
# For more information see: | ||
# - https://docs.github.com/en/actions/creating-actions/creating-a-composite-action | ||
# - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputsoutput_id | ||
|
||
# The action can be referenced in workflows like: | ||
# - ngxs/store/.github/actions/setup@master | ||
# - ./.github/actions/setup | ||
|
||
name: setup | ||
description: Set up environment | ||
|
||
inputs: | ||
node-version: | ||
description: Node version | ||
required: true | ||
default: 16.x | ||
github-ref-name: | ||
description: Branch name | ||
required: true | ||
default: ${{ github.ref_name }} | ||
github-sha: | ||
description: Commit hash | ||
required: true | ||
default: ${{ github.sha }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Don't save Bash session history | ||
shell: bash | ||
run: unset HISTFILE | ||
|
||
- name: Use Node.js ${{ inputs.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
check-latest: true | ||
|
||
- name: Configure kernel (increase watchers) | ||
shell: bash | ||
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p | ||
|
||
- name: Workspace cache | ||
uses: actions/cache@v3 | ||
id: workspace-cache | ||
env: | ||
cache-name: workspace-cache | ||
with: | ||
path: | | ||
~/.cache | ||
./node_modules | ||
./@ngxs | ||
./integrations/hello-world-ng11-ivy/dist-integration | ||
./integrations/hello-world-ng12-ivy/dist-integration | ||
./integrations/hello-world-ng13-ivy/dist-integration | ||
./integrations/hello-world-ng14-ivy/dist-integration | ||
key: ${{ runner.os }}-node-${{ inputs.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}-branch-${{ inputs.github-ref-name }}-sha-${{ inputs.github-sha }} | ||
restore-keys: | | ||
${{ runner.os }}-node-${{ inputs.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}-branch-${{ inputs.github-ref-name }}-sha- | ||
${{ runner.os }}-node-${{ inputs.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}-branch- | ||
${{ runner.os }}-node-${{ inputs.node-version }}-yarn- | ||
${{ runner.os }}- | ||
- name: Install project dependencies | ||
shell: bash | ||
run: yarn install --frozen-lockfile --non-interactive |
34 changes: 34 additions & 0 deletions
34
.github/actions/upload-integration-test-artifact/action.yml
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,34 @@ | ||
# For more information see: | ||
# - https://docs.github.com/en/actions/creating-actions/creating-a-composite-action | ||
# - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputsoutput_id | ||
|
||
# The action can be referenced in workflows like: | ||
# - ngxs/store/.github/actions/upload-integration-test-artifact@master | ||
# - ./.github/actions/upload-integration-test-artifact | ||
|
||
name: upload-integration-test-artifact | ||
description: Upload an integration test artifact with a name such as 'hello-world-ng11-ivy'. | ||
|
||
inputs: | ||
script: | ||
description: A script with a name such as 'integration:ng11:ivy' that generates an integration test artifact. | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Generate an artifact name | ||
id: artifact-name | ||
shell: bash | ||
run: | | ||
echo "Replace colons with dashes, substring 'integration' with a substring 'hello-world'. Example result: hello-world-ng11-ivy" | ||
echo "::set-output name=value::$(echo ${SCRIPT} | sed -r "s/:/-/g" | sed -r "s/integration/hello-world/g")" | ||
env: | ||
SCRIPT: ${{ inputs.script }} | ||
|
||
- name: Upload ${{ inputs.script }} artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ steps.artifact-name.outputs.value }} | ||
path: ./integrations/**/dist-integration/main.*.js | ||
retention-days: 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,146 @@ | ||
# For more information see: | ||
# - https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
# - https://docs.github.com/en/actions/learn-github-actions/contexts#github-context | ||
|
||
name: pr-validation | ||
|
||
on: | ||
pull_request: | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
concurrency: | ||
group: ${{ github.head_ref }}.${{ github.sha }}.pr-validation | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
premerge-build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
with: | ||
node-version: 16.x | ||
github-ref-name: ${{ github.ref_name }} | ||
github-sha: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Build NGXS | ||
run: yarn build | ||
|
||
premerge-test: | ||
runs-on: ubuntu-latest | ||
needs: premerge-build | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
script: [lint, eslint, 'test:ci'] | ||
|
||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
github-ref-name: ${{ github.ref_name }} | ||
github-sha: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Run ${{ matrix.script }} | ||
run: yarn ${{ matrix.script }} | ||
|
||
- name: Upload coverage results to Code Climate | ||
if: ${{ matrix.script == 'test:ci' }} | ||
run: | | ||
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > /tmp/cc-test-reporter | ||
chmod +x /tmp/cc-test-reporter | ||
/tmp/cc-test-reporter after-build --coverage-input-type lcov --exit-code 0 | ||
env: | ||
CC_TEST_REPORTER_ID: 3f4c9a9d57ded045e0f9ab5d23e5bbcbf709bb85637bea555f1233e72134b818 # TODO: better store it in the repository secrets. Name the variable: CC_TEST_REPORTER_ID. Then delete this line and uncomment the next one | ||
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | ||
|
||
premerge-integration-test: | ||
runs-on: ubuntu-latest | ||
needs: premerge-build | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
script: | ||
- 'integration:ng7' | ||
- 'integration:ng8' | ||
- 'integration:ng9:ivy:off' | ||
- 'integration:ng9:ivy' | ||
- 'integration:ng10:ivy:off' | ||
- 'integration:ng10:ivy' | ||
- 'integration:ng11:ivy:off' | ||
- 'integration:ng11:ivy' | ||
- 'integration:ng12:ivy' | ||
- 'integration:ng13:ivy' | ||
- 'integration:ng14:ivy' | ||
- 'test:types' | ||
|
||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
github-ref-name: ${{ github.ref_name }} | ||
github-sha: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Run ${{ matrix.script }} | ||
run: yarn ${{ matrix.script }} | ||
|
||
- name: Upload an integration test artifact | ||
if: ${{ matrix.script == 'integration:ng11:ivy' || matrix.script == 'integration:ng12:ivy' || matrix.script == 'integration:ng13:ivy' || matrix.script == 'integration:ng14:ivy' }} | ||
uses: ./.github/actions/upload-integration-test-artifact | ||
with: | ||
script: ${{ matrix.script }} | ||
|
||
premerge-bundlesize: | ||
runs-on: ubuntu-latest | ||
needs: premerge-integration-test | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
script: [bundlesize] | ||
|
||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
github-ref-name: ${{ github.ref_name }} | ||
github-sha: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Download integration test artifacts | ||
uses: ./.github/actions/download-integration-test-artifacts | ||
|
||
- name: Run ${{ matrix.script }} | ||
run: yarn ${{ matrix.script }} |
Oops, something went wrong.