-
Notifications
You must be signed in to change notification settings - Fork 85
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
Use binaries for CI testing 😋 #1196
Changes from 4 commits
088cc71
6bb7c41
ec2034b
361fb8d
d4833d3
05409de
aa524ab
88a8700
c746e43
ed6aa01
580e70f
686c1eb
d1123ea
21d1ab3
407e844
fb5007b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# GitHub Workflows | ||
|
||
General information about GH Workflows | ||
|
||
### Using `act` | ||
|
||
- Read it: https://github.com/nektos/act (Requires Docker) | ||
- Install it https://github.com/nektos/act#installation | ||
- Run it: `npm run test:act` | ||
- Clean it: `npm run test:act -- --clean` | ||
|
||
For more information, run: `npm run test:act -- --help` | ||
|
||
**Known Issues for `nektos/[email protected]`** | ||
|
||
`0.` The first time it will likely take ~3 minutes to run. Subsequent runs (with `--reuse`) should take less than 2 minutes. <br/> | ||
`1.` Artifact upload and download doesn't work on `nektos/act` (hence why we need to copy the zowe.tgz to a shared Docker volume). <br/> | ||
`2.` `nektos/act` only works with linux distros. <br/> | ||
`3.` `Install Rust toolchain` step was replaced with simple `yum install cargo -y` because `actions-rs/toolchain@v1` doesn't really work with `nektos/act`. <br/> | ||
`4.` Steps context (`steps.<id>`) doesn't really work on `nektos/act` (hence why we force unit and integration tests to run). <br/> | ||
`5.` Pipeline cannot be stopped (`Ctrl+C`) during most steps unless you kill your docker daemon. <br/> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"head_commit": { | ||
"message": "test" | ||
}, | ||
"inputs": { | ||
"binary-type": "debug" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
name: Zowe CLI | ||
'on': | ||
push: | ||
paths-ignore: | ||
- zowex/** | ||
- .github/workflows/rust-cli*.yml | ||
pull_request: | ||
paths-ignore: | ||
- zowex/** | ||
- .github/workflows/rust-cli*.yml | ||
workflow_dispatch: | ||
inputs: | ||
binary-type: | ||
description: Specify whether to use a `debug` or a `release` version of the binary | ||
default: debug | ||
required: false | ||
jobs: | ||
prebuild: | ||
name: Build Linux | ||
runs-on: ubuntu-latest | ||
container: quay.io/pypa/manylinux2014_x86_64 | ||
if: '(github.event_name == ''push'' || github.event.pull_request.head.repo.full_name != github.repository) && !contains(github.event.head_commit.message, ''[ci skip]'')' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install Rust toolchain | ||
if: (!github.event.run_with_act) | ||
id: install-rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- name: Install Rust toolchain | ||
if: github.event.run_with_act | ||
run: | | ||
yum install cargo -y | ||
cargo --version | ||
- name: Build | ||
run: 'cargo build --verbose ${{ github.event.inputs.binary-type == ''release'' && ''--release'' || '''' }} --manifest-path=zowex/Cargo.toml' | ||
- name: Create Archive | ||
run: 'tar -cvzf zowe.tgz -C zowex/target/${{ github.event.inputs.binary-type == ''release'' && ''release'' || ''debug'' }} zowe' | ||
- name: Upload the Prebuilt Linux Binary | ||
if: (!github.event.run_with_act) | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: zowe-linux-latest.tgz | ||
path: zowe.tgz | ||
- name: Upload the Prebuilt Linux Binary | ||
if: (github.event.run_with_act) | ||
run: mkdir -p /toolcache/artifacts && cp zowe.tgz /toolcache/artifacts/zowe-linux-latest.tgz | ||
test: | ||
name: Cross-Platform Test | ||
runs-on: '${{ matrix.os }}' | ||
needs: prebuild | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: | ||
- 16.x | ||
os: | ||
- ubuntu-latest | ||
env: | ||
OS: '${{ matrix.os }}' | ||
NODE: '${{ matrix.node-version }}' | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
if: '(github.event_name == ''push'' || github.event.pull_request.head.repo.full_name != github.repository) && !contains(github.event.head_commit.message, ''[ci skip]'')' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: 'Use Node.js ${{ matrix.node-version }}' | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '${{ matrix.node-version }}' | ||
- name: Get NPM Version | ||
id: npm-version | ||
run: 'echo "::set-output name=number::$(npm --version)"' | ||
- name: Use NPM v8 | ||
id: npm8 | ||
run: npm install -g npm@^8 | ||
- name: Install Node Package Dependencies | ||
id: install | ||
run: npm ci | ||
- name: Use Original NPM Version | ||
id: original-npm-version | ||
run: 'npm install -g npm@${{ steps.npm-version.outputs.number }}' | ||
- name: Build Source | ||
id: build | ||
run: npm run build --if-present | ||
- name: Build Windows Binary | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
cargo build --verbose ${{ github.event.inputs.binary-type == 'release' && '--release' || '' }} --manifest-path=zowex/Cargo.toml | ||
tar -cvzf zowe.tgz -C zowex/target/${{ github.event.inputs.binary-type == 'release' && 'release' || 'debug' }} zowe.exe | ||
- name: Build MacOS Binary | ||
if: matrix.os == 'macos-latest' | ||
run: | | ||
cargo build --verbose ${{ github.event.inputs.binary-type == 'release' && '--release' || '' }} --manifest-path=zowex/Cargo.toml | ||
tar -cvzf zowe.tgz -C zowex/target/${{ github.event.inputs.binary-type == 'release' && 'release' || 'debug' }} zowe | ||
- name: Download Prebuilt Linux Binary | ||
if: matrix.os == 'ubuntu-latest' && !github.event.run_with_act | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: zowe-linux-latest.tgz | ||
- name: Download Prebuilt Linux Binary | ||
if: matrix.os == 'ubuntu-latest' && github.event.run_with_act | ||
run: cp /toolcache/artifacts/zowe-linux-latest.tgz zowe.tgz | ||
- name: Archive Binary | ||
if: matrix.os != 'ubuntu-latest' | ||
id: upload-binary | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: 'zowe-${{ matrix.os }}.tgz' | ||
path: zowe.tgz | ||
- name: Setup Binary in PATH | ||
id: setup-binary | ||
run: tar -xvzf zowe.tgz -C ./node_modules/.bin --overwrite | ||
- name: Unit Tests | ||
id: unit | ||
if: '${{ always() && steps.build.outcome == ''success'' }} || github.event.run_with_act' | ||
run: 'npm run test:unit >> unit-tests.txt' | ||
- name: Integration Tests | ||
id: integration | ||
if: '${{ always() && steps.build.outcome == ''success'' }} || github.event.run_with_act' | ||
run: 'npm run test:integration >> integration-tests.txt' | ||
- name: Archive Results | ||
id: upload | ||
if: '${{ always() && steps.build.outcome == ''success'' }} && !github.event.run_with_act' | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: '${{ matrix.os }}-${{ matrix.node-version }}-results' | ||
path: | | ||
__tests__/__results__/ | ||
unit-tests.txt | ||
integration-tests.txt | ||
- name: Upload Results to Codecov | ||
if: '${{ always() && steps.build.outcome == ''success'' }} && !github.event.run_with_act' | ||
uses: codecov/[email protected] | ||
with: | ||
env_vars: 'OS,NODE' |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,7 +1,7 @@ | ||||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||||
|
||||
name: Zowe CLI CI | ||||
name: Zowe CLI | ||||
|
||||
on: | ||||
push: | ||||
|
@@ -12,12 +12,50 @@ on: | |||
paths-ignore: | ||||
- 'zowex/**' | ||||
- '.github/workflows/rust-cli*.yml' | ||||
workflow_dispatch: | ||||
inputs: | ||||
binary-type: | ||||
description: "Specify whether to use a `debug` or a `release` version of the binary" | ||||
default: "debug" | ||||
required: false | ||||
|
||||
jobs: | ||||
test: | ||||
prebuild: | ||||
name: Build Linux | ||||
runs-on: ubuntu-latest | ||||
|
||||
runs-on: ${{ matrix.os }} | ||||
# Need to build in container with old version of GLIBC to support RHEL 7 | ||||
# https://kobzol.github.io/rust/ci/2021/05/07/building-rust-binaries-in-ci-that-work-with-older-glibc.html | ||||
container: quay.io/pypa/manylinux2014_x86_64 | ||||
|
||||
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) && !contains(github.event.head_commit.message, '[ci skip]') | ||||
steps: | ||||
- uses: actions/checkout@v2 | ||||
|
||||
- name: Install Rust toolchain | ||||
id: install-rust | ||||
uses: actions-rs/toolchain@v1 | ||||
with: | ||||
profile: minimal | ||||
toolchain: stable | ||||
override: true | ||||
|
||||
- name: Build | ||||
run: cargo build --verbose ${{ github.event.inputs.binary-type == 'release' && '--release' || '' }} --manifest-path=zowex/Cargo.toml | ||||
|
||||
- name: Create Archive | ||||
run: tar -cvzf zowe.tgz -C zowex/target/${{ github.event.inputs.binary-type == 'release' && 'release' || 'debug' }} zowe | ||||
|
||||
- name: Upload the Prebuilt Linux Binary | ||||
uses: actions/upload-artifact@v2 | ||||
with: | ||||
name: zowe-linux-latest.tgz | ||||
path: zowe.tgz | ||||
|
||||
test: | ||||
name: Cross-Platform Test | ||||
runs-on: ${{ matrix.os }} | ||||
needs: prebuild | ||||
strategy: | ||||
fail-fast: false | ||||
matrix: | ||||
|
@@ -30,45 +68,85 @@ jobs: | |||
NODE_OPTIONS: --max_old_space_size=4096 | ||||
|
||||
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) && !contains(github.event.head_commit.message, '[ci skip]') | ||||
|
||||
steps: | ||||
- name: Checkout | ||||
uses: actions/checkout@v2 | ||||
|
||||
- name: Use Node.js ${{ matrix.node-version }} | ||||
uses: actions/setup-node@v1 | ||||
uses: actions/setup-node@v2 | ||||
with: | ||||
node-version: ${{ matrix.node-version }} | ||||
|
||||
- name: Use NPM v7 | ||||
id: npm7 | ||||
run: npm install -g npm@^7 | ||||
- name: Get NPM Version | ||||
id: npm-version | ||||
run: echo "::set-output name=number::$(npm --version)" | ||||
|
||||
- name: Use NPM v8 | ||||
id: npm8 | ||||
run: npm install -g npm@^8 | ||||
|
||||
- name: Install Node Package Dependencies | ||||
id: install | ||||
run: npm ci | ||||
|
||||
- name: Use Original NPM Version | ||||
id: original-npm-version | ||||
run: npm install -g npm@${{ steps.npm-version.outputs.number }} | ||||
|
||||
- name: Build Source | ||||
id: build | ||||
run: npm run build --if-present | ||||
|
||||
- name: Build Windows Binary | ||||
if: matrix.os == 'windows-latest' | ||||
run: | | ||||
cargo build --verbose ${{ github.event.inputs.binary-type == 'release' && '--release' || '' }} --manifest-path=zowex/Cargo.toml | ||||
tar -cvzf zowe.tgz -C zowex/target/${{ github.event.inputs.binary-type == 'release' && 'release' || 'debug' }} zowe.exe | ||||
|
||||
- name: Build MacOS Binary | ||||
if: matrix.os == 'macos-latest' | ||||
run: | | ||||
cargo build --verbose ${{ github.event.inputs.binary-type == 'release' && '--release' || '' }} --manifest-path=zowex/Cargo.toml | ||||
tar -cvzf zowe.tgz -C zowex/target/${{ github.event.inputs.binary-type == 'release' && 'release' || 'debug' }} zowe | ||||
|
||||
- name: Download Prebuilt Linux Binary | ||||
if: matrix.os == 'ubuntu-latest' | ||||
uses: actions/download-artifact@v2 | ||||
with: | ||||
name: zowe-linux-latest.tgz | ||||
|
||||
- name: Archive Binary | ||||
if: matrix.os != 'ubuntu-latest' | ||||
id: upload-binary | ||||
uses: actions/upload-artifact@v2 | ||||
with: | ||||
name: zowe-${{ matrix.os }}.tgz | ||||
path: zowe.tgz | ||||
|
||||
- name: Setup Binary in PATH | ||||
id: setup-binary | ||||
run: tar -xvzf zowe.tgz -C ./node_modules/.bin --overwrite | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should ./node_modules/.bin also be the location that the "zowe config daemon" command puts the zowe executable at a customer site? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think
Maybe something along the lines of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Makes sense. Many customers may not even have the privilege to write to those NodeJS locations when they run the "zowe config daemon" command. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note:
|
||||
|
||||
- name: Unit Tests | ||||
id: unit | ||||
if: ${{ always() && steps.build.outcome == 'success' }} | ||||
run: npm run test:unit >> file.txt | ||||
run: npm run test:unit >> unit-tests.txt | ||||
|
||||
- name: Integration Tests | ||||
id: integration | ||||
if: ${{ always() && steps.build.outcome == 'success' }} | ||||
run: npm run test:integration >> file.txt | ||||
run: npm run test:integration >> integration-tests.txt | ||||
|
||||
- name: Archive Results | ||||
id: upload | ||||
if: ${{ always() && steps.build.outcome == 'success' }} | ||||
uses: actions/upload-artifact@v2 | ||||
with: | ||||
name: ${{ matrix.os }}-${{ matrix.node-version }}-results | ||||
path: __tests__/__results__/ | ||||
path: | | ||||
__tests__/__results__/ | ||||
unit-tests.txt | ||||
integration-tests.txt | ||||
|
||||
- name: Upload Results to Codecov | ||||
if: ${{ always() && steps.build.outcome == 'success' }} | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nektos/act doc implies that it runs on windows. Is your statement due to the fact that nektos/act only hosts Linux docker images?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, I will rephrase that statement 👍
It should work fine on Windows, Linux, MacOS, and almost everywhere you can have Docker (e.g. Raspberry PI - armv7l) 😋