Skip to content

Commit

Permalink
CI: factor out yarn install dependencies
Browse files Browse the repository at this point in the history
We have a fixed set of setup we need to do to do `yarn install` (getting
NodeJS, golang, and python toolchains; setting up the `M1` flag; etc.).
Refactor those into a shared reusable workflow so it will be easier to
change in the future.

Signed-off-by: Mark Yen <mark.yen@suse.com>
  • Loading branch information
mook-as committed Oct 2, 2024
1 parent 4d05021 commit 0c4812d
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 378 deletions.
54 changes: 54 additions & 0 deletions .github/actions/yarn-install/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Yarn Install
description: >-
This is a composite action that does everything needed to do `yarn install`.
Checking out the source is optional; however, it must be done before this if
it was disabled. This may be necessary for more complex checkout scenarios.
inputs:
checkout:
description: Whether to check out the repository.
default: 'true'

runs:
using: composite
steps:
- if: inputs.checkout
uses: actions/checkout@v4
with:
persist-credentials: false

# In case we're running on a self-hosted runner without `yarn` installed,
# set up NodeJS, enable `yarn`, and then handle the caching.
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- run: corepack enable yarn
shell: bash
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: yarn

- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: src/go/**/go.sum

- uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- run: pip install setuptools
shell: bash

- name: Install Windows dependencies
if: runner.os == 'Windows'
shell: powershell
run: .\scripts\windows-setup.ps1 -SkipVisualStudio -SkipTools

- name: Flag build for M1
if: runner.os == 'macOS' && runner.arch == 'ARM64'
run: echo "M1=1" >> "${GITHUB_ENV}"
shell: bash

- run: yarn install --frozen-lockfile
shell: bash
16 changes: 2 additions & 14 deletions .github/workflows/docker-cli-monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,9 @@ jobs:
with:
fetch-depth: 0

- uses: actions/setup-node@v4
- uses: ./.github/actions/yarn-install
with:
node-version-file: package.json
cache: yarn
- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: src/go/**/go.sum
- uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- run: pip install setuptools

- run: yarn install --frozen-lockfile
checkout: false

- run: yarn dcmonitor
env:
Expand Down
22 changes: 2 additions & 20 deletions .github/workflows/go-work-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ jobs:
id-token: write # Required for ./.github/actions/get-token
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- id: get-token
uses: ./.github/actions/get-token
with:
Expand All @@ -39,30 +36,15 @@ jobs:
ref: ${{ github.head_ref }}
fetch-depth: 3
token: ${{ steps.get-token.outputs.token }}
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: yarn
- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: '**/go.sum'
- uses: actions/setup-python@v5
- uses: ./.github/actions/yarn-install
with:
python-version: '3.x'
cache: pip
- run: pip install setuptools
checkout: false
- name: Determine go.mod files
id: go-files
run: >-
printf "go-files=%s go.work\n"
"$(git ls-files '**/go.mod' '**/go.sum' | tr '\r\n' ' ')"
>> "$GITHUB_OUTPUT"
- run: yarn install --frozen-lockfile
- run: yarn lint:go:fix
- name: Check for changes
id: changed
Expand Down
25 changes: 1 addition & 24 deletions .github/workflows/linux-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,7 @@ jobs:
timeout-minutes: 150
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
# For compatibility with runners without yarn, we need to install node
# once, install yarn, then install node again to get caching.
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- run: npm install --global yarn
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: yarn
- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: src/go/**/go.sum
- uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- run: pip install setuptools
- name: Install dependencies
run: yarn install --frozen-lockfile
- uses: ./.github/actions/yarn-install
- name: Disable admin-access before start up
run: |
mkdir -p $HOME/.config/rancher-desktop
Expand Down
34 changes: 1 addition & 33 deletions .github/workflows/macM1-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,7 @@ jobs:
env:
M1: 1
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
ref: main
# For compatibility with runners without yarn, we need to install node
# once, install yarn, then install node again to get caching.
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- run: npm install --global yarn
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: yarn
- uses: actions/setup-go@v5
with:
go-version: go.work
cache-dependency-path: src/go/**/go.sum
- uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- run: pip install setuptools
- name: Install dependencies
run: yarn install --frozen-lockfile
#The next steps is a workaround for an unexpected failure in launching electron before running e2e tests
#Such failure is addressed in issue #2915
- name: add tools to PATH
run: |
rm -fr $HOME/.rd/bin
mkdir -p $HOME/.rd/bin
cp -rf $HOME/actions-runner/_work/rancher-desktop/rancher-desktop/resources/darwin/bin/ $HOME/.rd/bin/
export PATH="$HOME/.rd/bin:$PATH"
- uses: ./.github/actions/yarn-install
- name: Disable admin-access before start up
run: |
mkdir -p $HOME/Library/Preferences/rancher-desktop
Expand Down
64 changes: 4 additions & 60 deletions .github/workflows/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,9 @@ jobs:
persist-credentials: false
# Needed to run `git describe` to get full version info
fetch-depth: 0
- uses: actions/setup-node@v4
- uses: ./.github/actions/yarn-install
with:
node-version-file: package.json
cache: yarn
- uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: src/go/**/go.sum
- name: Install Windows dependencies
if: runner.os == 'Windows'
shell: powershell
run: .\scripts\windows-setup.ps1 -SkipVisualStudio -SkipTools
- name: Flag build for M1
if: matrix.arch == 'aarch64' && matrix.platform == 'mac'
run: echo "M1=1" >> "${GITHUB_ENV}"
- run: pip install setuptools
- # Needs a network timeout for macos & windows. See https://github.com/yarnpkg/yarn/issues/8242 for more info
run: yarn install --frozen-lockfile --network-timeout 1000000
checkout: false
- run: yarn build
- run: yarn package
- name: Build bats.tar.gz
Expand Down Expand Up @@ -163,27 +144,7 @@ jobs:
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Windows dependencies
shell: powershell
run: .\scripts\windows-setup.ps1 -SkipVisualStudio -SkipTools
- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: src/go/**/go.sum
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: yarn
- uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- run: pip install setuptools
# Needs a network timeout for macos & windows. See https://github.com/yarnpkg/yarn/issues/8242 for more info
- run: yarn install --frozen-lockfile --network-timeout 1000000
- uses: ./.github/actions/yarn-install
- uses: actions/download-artifact@v4
name: Download artifact
with:
Expand Down Expand Up @@ -233,24 +194,7 @@ jobs:
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: src/go/**/go.sum
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: yarn
- uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- run: pip install setuptools
# Needs a network timeout for macos & windows. See https://github.com/yarnpkg/yarn/issues/8242 for more info
- run: yarn install --frozen-lockfile --network-timeout 1000000
- uses: ./.github/actions/yarn-install
- uses: actions/download-artifact@v4
name: Download artifact
with:
Expand Down
18 changes: 2 additions & 16 deletions .github/workflows/rddepman.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,9 @@ jobs:
with:
fetch-depth: 0

- uses: actions/setup-go@v5
- uses: ./.github/actions/yarn-install
with:
go-version-file: go.work
cache-dependency-path: src/go/**/go.sum

- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: yarn

- uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip

- run: pip install setuptools
- run: yarn install --frozen-lockfile
checkout: false

- run: yarn rddepman
env:
Expand Down
21 changes: 2 additions & 19 deletions .github/workflows/release-merge-to-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,9 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: ./.github/actions/yarn-install
with:
node-version-file: package.json
- run: corepack enable yarn
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: yarn
- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: src/go/**/go.sum
- uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- run: pip install setuptools

- run: yarn install --frozen-lockfile

checkout: false
- run: node scripts/ts-wrapper.js scripts/release-merge-to-main.ts
env:
GITHUB_WRITE_TOKEN: ${{ github.token }}
Expand Down
23 changes: 1 addition & 22 deletions .github/workflows/screenshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,8 @@ jobs:
env:
EXEC_COMMAND: # On Windows, we don't need any commands.

- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- run: corepack enable yarn
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: yarn
- uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: src/go/**/go.sum
- uses: ./.github/actions/yarn-install
- uses: ./.github/actions/setup-environment
- run: pip install setuptools
- # Needs a network timeout for macos & windows. See https://github.com/yarnpkg/yarn/issues/8242 for more info
run: yarn install --frozen-lockfile --network-timeout 1000000
- name: Override version
if: inputs.mock_version
run: echo "RD_MOCK_VERSION=${{ inputs.mock_version }}" >> "${GITHUB_ENV}"
Expand Down
Loading

0 comments on commit 0c4812d

Please sign in to comment.