-
Notifications
You must be signed in to change notification settings - Fork 86
214 lines (177 loc) · 7.61 KB
/
zowe-cli.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# 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
on:
push:
pull_request:
workflow_dispatch:
inputs:
binary-type:
description: Specify whether to use a `debug` or a `release` version of the binary
default: debug
required: false
test-type:
description: Specify whether to run tests using the `binary` or regular `nodejs` executable
default: binary
required: false
imperative-branch:
description: Specify name of Imperative branch to checkout and build from source
required: false
jobs:
test:
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) && !contains(github.event.head_commit.message, '[ci skip]')
runs-on: ${{ matrix.os }}
outputs:
npm-resolutions: ${{ steps.npm-update.outputs.result }}
strategy:
fail-fast: false
matrix:
node-version: [16.x, 18.x]
os: [windows-latest, ubuntu-latest, macos-latest]
env:
OS: ${{ matrix.os }}
NODE: ${{ matrix.node-version }}
NODE_OPTIONS: --max_old_space_size=4096
timeout-minutes: 60
concurrency:
group: ${{ matrix.os }}-node-${{ matrix.node-version }}-ci-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
check-latest: true
- name: Disable Lint Annotations
run: |
echo "::remove-matcher owner=eslint-compact::"
echo "::remove-matcher owner=eslint-stylish::"
- name: Get NPM Version
id: npm-version
run: echo "number=$(npm --version)" >> $GITHUB_OUTPUT
- name: Use NPM v8
id: npm8
run: npm install -g npm@~8.3.2
- name: Install Dependencies
run: npm ci
- name: Update Dependencies
id: npm-update
uses: zowe-actions/octorelease/script@v1
with:
script: npmUpdate
- name: Use Original NPM Version
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' || github.event_name == 'push'
uses: dtolnay/rust-toolchain@stable
- name: Checkout Imperative
id: checkout-imperative
if: github.event_name == 'workflow_dispatch' && github.event.inputs.imperative-branch != ''
run: |
cd node_modules/@zowe && npx rimraf imperative
git clone --branch ${{ github.event.inputs.imperative-branch }} --depth 1 https://github.com/zowe/imperative.git
cd imperative && npm ci --ignore-scripts && npx tsc
- name: Build Source
id: build
run: npm run build
- name: Build Binary
id: build-binary
if: matrix.os != 'windows-latest' && (github.event.inputs.test-type == 'binary' || github.event_name == 'push')
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: Build Binary (Windows)
id: build-windows-binary
if: matrix.os == 'windows-latest' && (github.event.inputs.test-type == 'binary' || github.event_name == 'push')
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
env:
RUSTFLAGS: "-Ctarget-feature=+crt-static"
- name: Archive Binary
if: github.event.inputs.test-type == 'binary' || github.event_name == 'push'
id: upload-binary
uses: actions/upload-artifact@v3
with:
name: zowe-${{ matrix.os }}.tgz
path: zowe.tgz
- name: Setup Binary in PATH
if: github.event.inputs.test-type == 'binary' || github.event_name == 'push'
id: setup-binary
shell: bash
run: |
tar -xvzf zowe.tgz -C ./__tests__/__resources__/daemon_instances
echo "${{ github.workspace }}/__tests__/__resources__/application_instances" >> $GITHUB_PATH
- name: Test Rust EXE and zowe script
id: test-exe-and-script
if: ${{ steps.setup-binary.outcome == 'success' && (github.event.inputs.test-type == 'binary' || github.event_name == 'push') }}
run: cargo test ${{ github.event.inputs.binary-type == 'release' && '--release' || '' }} --manifest-path=zowex/Cargo.toml -- --nocapture
- name: Unit Tests
if: ${{ always() && steps.build.outcome == 'success' }}
run: npm run test:unit
- name: Unlock Keyring
id: unlock-keyring
if: ${{ always() && steps.build.outcome == 'success' && matrix.os == 'ubuntu-latest' }}
uses: t1m0thyj/unlock-keyring@v1
- name: Start Daemon on Windows only
id: start-daemon
if: ${{ always() && steps.build.outcome == 'success' && matrix.os == 'windows-latest' && (github.event.inputs.test-type == 'binary' || github.event_name == 'push') }}
run: ./__tests__/__resources__/daemon_instances/zowe
- name: Integration Tests (Native)
if: ${{ always() && steps.build.outcome == 'success' && !(github.event.inputs.test-type == 'binary' || github.event_name == 'push') }}
run: npm run test:integration
- name: Integration Tests (Daemon)
if: ${{ always() && steps.build.outcome == 'success' && (github.event.inputs.test-type == 'binary' || github.event_name == 'push') }}
run: npm run test:integration -- --runInBand
- name: Archive Results
if: ${{ always() && steps.build.outcome == 'success' }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-${{ matrix.node-version }}-results
path: __tests__/__results__/
- name: Upload Results to Codecov
if: ${{ always() && steps.build.outcome == 'success' }}
uses: codecov/codecov-action@v3
with:
env_vars: OS,NODE
release:
if: github.event_name == 'push' && github.ref_protected
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.ref }}
# Use Node 16 until npm@9 bundled with Node 18 becomes more stable
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install Dependencies
run: npm ci
- name: Update Dependencies
uses: zowe-actions/octorelease/script@v1
env:
GIT_COMMITTER_NAME: ${{ secrets.ZOWE_ROBOT_USER }}
GIT_COMMITTER_EMAIL: ${{ secrets.ZOWE_ROBOT_EMAIL }}
NPM_RESOLUTIONS: ${{ needs.test.outputs.npm-resolutions }}
with:
script: npmUpdate
- name: Build Source
run: npm run build
- uses: zowe-actions/octorelease@v1
env:
GIT_COMMITTER_NAME: ${{ secrets.ZOWE_ROBOT_USER }}
GIT_COMMITTER_EMAIL: ${{ secrets.ZOWE_ROBOT_EMAIL }}
GIT_CREDENTIALS: x-access-token:${{ secrets.ZOWE_ROBOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
NPM_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
NPM_EMAIL: ${{ secrets.ZOWE_ROBOT_EMAIL }}