Skip to content

Commit

Permalink
Extract common code and fail build if lock is modified (#3272)
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Caponetto <[email protected]>
  • Loading branch information
caponetto authored Jan 11, 2025
1 parent faf5a90 commit 51ce77e
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 28 deletions.
28 changes: 28 additions & 0 deletions .github/actions/install-ui-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Install UI dependencies"
description: "Install UI dependencies; fail the build if the lock file is not up-to-date"

inputs:
working_dir:
description: "Elyra path"
required: false
default: "."

runs:
using: "composite"
steps:
- name: Go to working directory
shell: bash
run: |
echo "Step: Go to working directory"
cd ${{ inputs.working_dir }}
- name: Install dependencies
shell: bash
run: |
echo "Step: Install dependencies"
make yarn-install
- name: "Check yarn.lock"
shell: bash
run: |
echo "Step: Check yarn.lock"
git diff yarn.lock;
[ "0" == "$(git diff yarn.lock | wc -l | tr -d ' ')" ]
27 changes: 27 additions & 0 deletions .github/actions/install-yarn/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Install Yarn"
description: "Install Yarn"

inputs:
working_dir:
description: "Elyra path"
required: false
default: "."
version:
description: "Yarn version"
required: true

runs:
using: "composite"
steps:
- name: Go to working directory
shell: bash
run: |
echo "Step: Go to working directory"
cd ${{ inputs.working_dir }}
- name: Install
shell: bash
run: |
echo "Step: Install"
corepack prepare yarn@${{ inputs.version }} --activate
yarn set version ${{ inputs.version }}
echo "Yarn version: $(yarn --version)"
53 changes: 25 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ jobs:
/home/runner/.cache/Cypress
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Install Yarn ${{ env.YARN_VERSION }}
run: |
corepack prepare yarn@${{ env.YARN_VERSION }} --activate
yarn set version ${{ env.YARN_VERSION }}
yarn --version
- name: Install dependencies
run: |
yarn install
uses: ./.github/actions/install-yarn
with:
version: ${{ env.YARN_VERSION }}
- name: Install UI dependencies
uses: ./.github/actions/install-ui-dependencies
lint-server:
name: Lint Server
runs-on: ubuntu-latest
Expand All @@ -75,13 +73,11 @@ jobs:
*/*/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Install Yarn ${{ env.YARN_VERSION }}
run: |
corepack prepare yarn@${{ env.YARN_VERSION }} --activate
yarn set version ${{ env.YARN_VERSION }}
yarn --version
- name: Install dependencies
run: |
make yarn-install
uses: ./.github/actions/install-yarn
with:
version: ${{ env.YARN_VERSION }}
- name: Install UI dependencies
uses: ./.github/actions/install-ui-dependencies
- name: Lint
run: make eslint-check-ui
- name: Check format
Expand Down Expand Up @@ -135,14 +131,14 @@ jobs:
*/*/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Install Yarn ${{ env.YARN_VERSION }}
run: |
corepack prepare yarn@${{ env.YARN_VERSION }} --activate
yarn set version ${{ env.YARN_VERSION }}
yarn --version
uses: ./.github/actions/install-yarn
with:
version: ${{ env.YARN_VERSION }}
- name: Install UI dependencies
uses: ./.github/actions/install-ui-dependencies
- name: Build
run: |
make build-dependencies
make yarn-install
make build-ui
- name: Install
run: make install-server
Expand All @@ -169,14 +165,14 @@ jobs:
/home/runner/.cache/Cypress
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Install Yarn ${{ env.YARN_VERSION }}
run: |
corepack prepare yarn@${{ env.YARN_VERSION }} --activate
yarn set version ${{ env.YARN_VERSION }}
yarn --version
uses: ./.github/actions/install-yarn
with:
version: ${{ env.YARN_VERSION }}
- name: Install UI dependencies
uses: ./.github/actions/install-ui-dependencies
- name: Build
run: |
make build-dependencies
make yarn-install
make build-ui
- name: Install
run: |
Expand Down Expand Up @@ -243,10 +239,11 @@ jobs:
/home/runner/.cache/Cypress
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Install Yarn ${{ env.YARN_VERSION }}
run: |
corepack prepare yarn@${{ env.YARN_VERSION }} --activate
yarn set version ${{ env.YARN_VERSION }}
yarn --version
uses: ./.github/actions/install-yarn
with:
version: ${{ env.YARN_VERSION }}
- name: Install UI dependencies
uses: ./.github/actions/install-ui-dependencies
- name: Build
run: |
make clean install
Expand Down

0 comments on commit 51ce77e

Please sign in to comment.