Skip to content

Commit

Permalink
updating workflows
Browse files Browse the repository at this point in the history
Signed-off-by: zFernand0 <[email protected]>
  • Loading branch information
zFernand0 committed Nov 15, 2021
1 parent 05409de commit aa524ab
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/_act_event.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
},
"inputs": {
"binary-type": "debug",
"test-type": "nodejs"
"test-type": "binary"
}
}
66 changes: 14 additions & 52 deletions .github/workflows/zowe-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,45 +24,9 @@ on:
required: false

jobs:
prebuild:
name: Build Linux
runs-on: ubuntu-latest

# 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.inputs.test-type == "binary" &&
(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:
Expand Down Expand Up @@ -100,30 +64,28 @@ jobs:
id: original-npm-version
run: npm install -g npm@${{ steps.npm-version.outputs.number }}

- name: Install Rust toolchain
id: install-rust
if: github.event.inputs.test-type == "binary"
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Build Source
id: build
run: npm run build --if-present

- name: Build Windows Binary
if: matrix.os == 'windows-latest' && github.event.inputs.test-type == "binary"
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' && github.event.inputs.test-type == "binary"
- name: Build Binary
id: build-binary
if: github.event.inputs.test-type == "binary"
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.inputs.test-type == "binary"
uses: actions/download-artifact@v2
with:
name: zowe-linux-latest.tgz
tar -cvzf zowe.tgz -C zowex/target/${{ github.event.inputs.binary-type == 'release' && 'release' || 'debug' }} zowe${{ matrix.os == 'windows-latest' && '.exe' || '' }}
- name: Archive Binary
if: matrix.os != 'ubuntu-latest' && github.event.inputs.test-type == "binary"
if: github.event.inputs.test-type == "binary"
id: upload-binary
uses: actions/upload-artifact@v2
with:
Expand Down
36 changes: 28 additions & 8 deletions scripts/testCliWorkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const fs = require("fs");
const path = require("path");
const yaml = require("js-yaml");
const chalk = require("chalk");
const rl = require("readline").createInterface({input: process.stdin, output: process.stdout});
const rl = require("readline").createInterface({ input: process.stdin, output: process.stdout });

const wfPath = ".github/workflows/zowe-cli.yml";
const epPath = ".github/_act_event.json";
Expand All @@ -44,7 +44,7 @@ const _sleep = async (ms) => {
const _handle = async (fun, msg) => {
try {
await fun();
} catch(_) {
} catch (_) {
if (msg) console.log(chalk.red(msg));
console.error(_.toString());
process.exit(1);
Expand All @@ -62,7 +62,7 @@ async function clean() {
for (const c of containers) {
if (c === "") continue;
if (await _yesno(`Remove Container: ${c}\nAre you sure? [y/n]`)) {
cp.spawn("docker", ["rm", c.split("'").join(""), "--force"], {stdio: "ignore"});
cp.spawn("docker", ["rm", c.split("'").join(""), "--force"], { stdio: "ignore" });
} else {
console.log(`Skip Container: ${c}`);
}
Expand Down Expand Up @@ -103,7 +103,7 @@ async function main() {
const artPath = "/toolcache/artifacts";
for (const [i, c] of v.steps.entries()) {
// Workaround for https://github.com/nektos/act/issues/465
if(c.if?.indexOf(".outcome") > 0) {
if (c.if?.indexOf(".outcome") > 0) {
v.steps[i].if = c.if.replaceAll(".outcome == 'success'", ".success");
v.steps[i].if = c.if.replaceAll(".outcome == 'failure'", ".success");
}
Expand Down Expand Up @@ -132,8 +132,19 @@ async function main() {
switch (c.id) {
case "install-rust": {
v.steps[i] = {
name: c.name,
run: "yum install cargo -y\ncargo --version\n"
...v.steps[i],
// run: "yum install cargo -y\ncargo --version\n"
run: "apt update -y\napt install build-essential curl -y\ncurl https://sh.rustup.rs -sSf > __install_rust.sh\nchmod u+x __install_rust.sh\n./__install_rust.sh -y\nsource $HOME/.cargo/env\ncargo --version\n"
};
delete v.steps[i].uses;
delete v.steps[i].with;
break;
}
case "build-binary": {
v.steps[i] = {
...v.steps[i],
// run: "yum install cargo -y\ncargo --version\n"
run: "source $HOME/.cargo/env\ncargo --version\n" + c.run
};
break;
}
Expand All @@ -147,7 +158,7 @@ async function main() {
console.log("Generating new workflow...");
await _sleep();
_handle(() => {
fs.writeFileSync(genWfPath, yaml.dump(wf, {indent: 2, lineWidth: -1}), {flag: "w"});
fs.writeFileSync(genWfPath, yaml.dump(wf, { indent: 2, lineWidth: -1 }), { flag: "w" });
}, `Unable to write "${genWfPath}"`);

if (process.argv.indexOf(opts.dryRun[0]) > 0 || process.argv.indexOf(opts.dryRun[1]) > 0) {
Expand All @@ -156,7 +167,16 @@ async function main() {
// Execute workflow locally
console.log("Executing new workflow...");
await _sleep();
cp.spawn("act", [`-r${verbose ? 'v' : ''}W`, genWfPath, "-e", epPath], {stdio: "inherit"});
cp.spawn("act", [`-r${verbose ? 'v' : ''}W`, genWfPath, "-e", epPath], { stdio: "inherit" });

console.log("Copying existing artifacts...");
await _sleep();
const copyPath = cp.execSync("docker inspect volume act-toolcache | jq '.[0].Mountpoint'", { encoding: "utf-8" }).trim().replaceAll('"', '');
const testPath = path.resolve(__dirname, "..", "__tests__", "__results__", "nektos_act");
cp.execSync(`mkdir -p ${path.join(copyPath, "artifacts")} && mkdir -p ${testPath}`);
cp.execSync(`tar -zc${verbose ? 'v' : ''}f __act__artifacts.tgz -C ${copyPath} .`);
cp.execSync(`tar -zx${verbose ? 'v' : ''}f __act__artifacts.tgz -C ${testPath}`);
cp.execSync(`rm -rf __act__artifacts.tgz`);
}
}

Expand Down

0 comments on commit aa524ab

Please sign in to comment.