Skip to content

Commit ae2b29a

Browse files
committed
Extract common code to dedicated GitHub actions and fail the build if the lock file is not up-to-date
Signed-off-by: Guilherme Caponetto <638737+caponetto@users.noreply.github.com>
1 parent 6eef65b commit ae2b29a

3 files changed

Lines changed: 80 additions & 28 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Install UI dependencies"
2+
description: "Install UI dependencies; fail the build if the lock file is not up-to-date"
3+
4+
inputs:
5+
working_dir:
6+
description: "Elyra path"
7+
required: false
8+
default: "."
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Go to working directory
14+
shell: bash
15+
run: |
16+
echo "Step: Go to working directory"
17+
cd ${{ inputs.working_dir }}
18+
- name: Install dependencies
19+
shell: bash
20+
run: |
21+
echo "Step: Install dependencies"
22+
make yarn-install
23+
- name: "Check yarn.lock"
24+
shell: bash
25+
run: |
26+
echo "Step: Check yarn.lock"
27+
git diff yarn.lock;
28+
[ "0" == "$(git diff yarn.lock | wc -l | tr -d ' ')" ]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Install Yarn"
2+
description: "Install Yarn"
3+
4+
inputs:
5+
working_dir:
6+
description: "Elyra path"
7+
required: false
8+
default: "."
9+
version:
10+
description: "Yarn version"
11+
required: true
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Go to working directory
17+
shell: bash
18+
run: |
19+
echo "Step: Go to working directory"
20+
cd ${{ inputs.working_dir }}
21+
- name: Install
22+
shell: bash
23+
run: |
24+
echo "Step: Install"
25+
corepack prepare yarn@${{ inputs.version }} --activate
26+
yarn set version ${{ inputs.version }}
27+
echo "Yarn version: $(yarn --version)"

.github/workflows/build.yml

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ jobs:
4444
/home/runner/.cache/Cypress
4545
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
4646
- name: Install Yarn ${{ env.YARN_VERSION }}
47-
run: |
48-
corepack prepare yarn@${{ env.YARN_VERSION }} --activate
49-
yarn set version ${{ env.YARN_VERSION }}
50-
yarn --version
51-
- name: Install dependencies
52-
run: |
53-
yarn install
47+
uses: ./.github/actions/install-yarn
48+
with:
49+
version: ${{ env.YARN_VERSION }}
50+
- name: Install UI dependencies
51+
uses: ./.github/actions/install-ui-dependencies
5452
lint-server:
5553
name: Lint Server
5654
runs-on: ubuntu-latest
@@ -75,13 +73,11 @@ jobs:
7573
*/*/node_modules
7674
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
7775
- name: Install Yarn ${{ env.YARN_VERSION }}
78-
run: |
79-
corepack prepare yarn@${{ env.YARN_VERSION }} --activate
80-
yarn set version ${{ env.YARN_VERSION }}
81-
yarn --version
82-
- name: Install dependencies
83-
run: |
84-
make yarn-install
76+
uses: ./.github/actions/install-yarn
77+
with:
78+
version: ${{ env.YARN_VERSION }}
79+
- name: Install UI dependencies
80+
uses: ./.github/actions/install-ui-dependencies
8581
- name: Lint
8682
run: make eslint-check-ui
8783
- name: Check format
@@ -135,14 +131,14 @@ jobs:
135131
*/*/node_modules
136132
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
137133
- name: Install Yarn ${{ env.YARN_VERSION }}
138-
run: |
139-
corepack prepare yarn@${{ env.YARN_VERSION }} --activate
140-
yarn set version ${{ env.YARN_VERSION }}
141-
yarn --version
134+
uses: ./.github/actions/install-yarn
135+
with:
136+
version: ${{ env.YARN_VERSION }}
137+
- name: Install UI dependencies
138+
uses: ./.github/actions/install-ui-dependencies
142139
- name: Build
143140
run: |
144141
make build-dependencies
145-
make yarn-install
146142
make build-ui
147143
- name: Install
148144
run: make install-server
@@ -169,14 +165,14 @@ jobs:
169165
/home/runner/.cache/Cypress
170166
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
171167
- name: Install Yarn ${{ env.YARN_VERSION }}
172-
run: |
173-
corepack prepare yarn@${{ env.YARN_VERSION }} --activate
174-
yarn set version ${{ env.YARN_VERSION }}
175-
yarn --version
168+
uses: ./.github/actions/install-yarn
169+
with:
170+
version: ${{ env.YARN_VERSION }}
171+
- name: Install UI dependencies
172+
uses: ./.github/actions/install-ui-dependencies
176173
- name: Build
177174
run: |
178175
make build-dependencies
179-
make yarn-install
180176
make build-ui
181177
- name: Install
182178
run: |
@@ -243,10 +239,11 @@ jobs:
243239
/home/runner/.cache/Cypress
244240
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
245241
- name: Install Yarn ${{ env.YARN_VERSION }}
246-
run: |
247-
corepack prepare yarn@${{ env.YARN_VERSION }} --activate
248-
yarn set version ${{ env.YARN_VERSION }}
249-
yarn --version
242+
uses: ./.github/actions/install-yarn
243+
with:
244+
version: ${{ env.YARN_VERSION }}
245+
- name: Install UI dependencies
246+
uses: ./.github/actions/install-ui-dependencies
250247
- name: Build
251248
run: |
252249
make clean install

0 commit comments

Comments
 (0)