Skip to content

Commit

Permalink
Extract common code and fail build if lock is modified (elyra-ai#3272)
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Caponetto <[email protected]>
  • Loading branch information
caponetto committed Jan 15, 2025
1 parent e447121 commit ff3cbda
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 40 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 ' ')" ]
28 changes: 28 additions & 0 deletions .github/actions/install-yarn/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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 }}
git checkout package.json
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 @@ -47,13 +47,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 Down Expand Up @@ -82,13 +80,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 @@ -147,14 +143,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-prod
- name: Install
run: make install-server
Expand Down Expand Up @@ -185,14 +181,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 test-instrument
make build-ui-prod
- name: Install
Expand Down Expand Up @@ -270,10 +266,9 @@ 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: Check whether to build container images
id: should-build-images
run: |
Expand All @@ -282,6 +277,8 @@ jobs:
if: steps.should-build-images.outputs.result == 'true'
run: |
./.github/workflows/scripts/free_gha_space.sh
- name: Install UI dependencies
uses: ./.github/actions/install-ui-dependencies
- name: Build
run: |
make install-prod
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}
- 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: Check version
if: ${{ github.repository_owner == 'opendatahub-io' && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.dry_run)) }}
run: |
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/update-version-through-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ jobs:
node-version: ${{ env.NODE_VERSION }}

- name: Install Yarn ${{ env.YARN_VERSION }}
run: |
corepack prepare yarn@${{ env.YARN_VERSION }} --activate
yarn set version ${{ env.YARN_VERSION }}
git checkout package.json
yarn --version
uses: ./.github/actions/install-yarn
with:
version: ${{ env.YARN_VERSION }}

- name: Install dependencies
run: |
make yarn-install
- name: Install UI dependencies
uses: ./.github/actions/install-ui-dependencies

- name: Update version to ${{ github.event.inputs.version }}
id: update
Expand Down

0 comments on commit ff3cbda

Please sign in to comment.