Skip to content

Commit

Permalink
Merge pull request #6778 from mook-as/ci/setup-for-run
Browse files Browse the repository at this point in the history
CI: Use shared steps for setting up environment
  • Loading branch information
jandubois authored Apr 25, 2024
2 parents 283f49f + ed58a72 commit 2ee7c23
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 143 deletions.
66 changes: 66 additions & 0 deletions .github/actions/setup-environment/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Setup Environment
description: >-
This is a composite action that is used to set up the runner for running
Rancher Desktop.
runs:
using: composite
steps:
- name: "Linux: Enable KVM access"
if: runner.os == 'Linux'
shell: bash
run: sudo chmod a+rwx /dev/kvm

- name: "Windows: Stop unwanted services"
if: runner.os == 'Windows'
shell: pwsh
run: >-
Get-Service -ErrorAction Continue -Name
@('W3SVC', 'docker')
| Stop-Service
- name: "Windows: Update any pre-installed WSL"
if: runner.os == 'Windows'
shell: pwsh
run: |
# Sometimes this results in a HTTP 403 for some reason; in that case, we
# need to retry.
do {
try {
wsl --update
break
} catch [Exception] {
Write-Host $_.Exception.Message
}
} while ($true)
- name: "Windows: Finish setting up WSL"
if: runner.os == 'Windows'
shell: pwsh
run: wsl --set-default-version 2

- name: "Linux: Initialize pass"
if: runner.os == 'Linux'
shell: bash
run: |
# Configure the agent to allow default passwords
HOMEDIR="$(gpgconf --list-dirs homedir)" # spellcheck-ignore-line
mkdir -p "${HOMEDIR}"
chmod 0700 "${HOMEDIR}"
echo "allow-preset-passphrase" >> "${HOMEDIR}/gpg-agent.conf"
# Create a GPG key
gpg --quick-generate-key --yes --batch --passphrase '' \
[email protected] default \
default never
# Get info about the newly created key
DATA="$(gpg --batch --with-colons --with-keygrip --list-secret-keys)"
FINGERPRINT="$(awk -F: '/^fpr:/ { print $10 ; exit }' <<< "${DATA}")" # spellcheck-ignore-line
GRIP="$(awk -F: '/^grp:/ { print $10 ; exit }' <<< "${DATA}")"
# Save the password
gpg-connect-agent --verbose "PRESET_PASSPHRASE ${GRIP} -1 00" /bye
# Initialize pass
pass init "${FINGERPRINT}"
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ containo
copypac
coredns
corejs
corepack
coreutils
crd
credfwd
Expand Down
48 changes: 5 additions & 43 deletions .github/workflows/bats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jobs:
sparse-checkout-cone-mode: false
sparse-checkout: |
scripts/install-latest-ci.sh
.github/actions/setup-environment/action.yaml
.github/workflows/bats/sanitize-artifact-name.sh
- name: Install latest CI build
Expand All @@ -121,64 +122,25 @@ jobs:
BATS_DIR: ${{ github.workspace }}/bats
ZIP_NAME: ${{ github.workspace }}/version.txt

- name: "Linux: Enable KVM access"
if: runner.os == 'Linux'
run: sudo chmod a+rwx /dev/kvm

- name: "Windows: Stop unwanted services"
if: runner.os == 'Windows'
run: >-
Get-Service -ErrorAction Continue -Name
@('W3SVC', 'docker')
| Stop-Service
- name: "Windows: Update any pre-installed WSL"
if: runner.os == 'Windows'
run: wsl --update
continue-on-error: true
- name: Set up environment
uses: ./.github/actions/setup-environment

- name: "Windows: Install WSL2 Distribution"
if: runner.os == 'Windows'
shell: pwsh
run: |
# Set the default WSL version (we don't work with WSL1)
wsl --set-default-version 2
# Install Debian, but do not launch it
wsl --install Debian --no-launch
# Initialize Debian, without going through any first-time setup
debian.exe install --root
shell: pwsh
- name: "Windows: Install prerequisites in WSL"
if: runner.os == 'Windows'
shell: pwsh
run: >-
wsl.exe -d Debian --exec /usr/bin/env DEBIAN_FRONTEND=noninteractive
sh -c 'apt-get update && apt-get install --yes curl'
- name: "Linux: Initialize pass"
if: runner.os == 'Linux'
run: |
# Configure the agent to allow default passwords
HOMEDIR="$(gpgconf --list-dirs homedir)" # spellcheck-ignore-line
mkdir -p "${HOMEDIR}"
chmod 0700 "${HOMEDIR}"
echo "allow-preset-passphrase" >> "${HOMEDIR}/gpg-agent.conf"
# Create a GPG key
gpg --quick-generate-key --yes --batch --passphrase '' \
[email protected] default \
default never
# Get info about the newly created key
DATA="$(gpg --batch --with-colons --with-keygrip --list-secret-keys)"
FINGERPRINT="$(awk -F: '/^fpr:/ { print $10 ; exit }' <<< "${DATA}")" # spellcheck-ignore-line
GRIP="$(awk -F: '/^grp:/ { print $10 ; exit }' <<< "${DATA}")"
# Save the password
gpg-connect-agent --verbose "PRESET_PASSPHRASE ${GRIP} -1 00" /bye
# Initialize pass
pass init "${FINGERPRINT}"
- name: Set log directory
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-merge-to-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- run: corepack enable yarn # spellcheck-ignore-line
- run: corepack enable yarn
- uses: actions/setup-node@v4
with:
node-version-file: package.json
Expand Down
46 changes: 2 additions & 44 deletions .github/workflows/screenshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,54 +34,11 @@ jobs:
brew update
brew install smokris/getwindowid/getwindowid
- name: "Linux: Enable KVM access"
if: runner.os == 'Linux'
run: sudo chmod a+rwx /dev/kvm
- name: "Linux: Install Tools"
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install graphicsmagick x11-utils mutter # spellcheck-ignore-line
- name: "Linux: Initialize pass"
if: runner.os == 'Linux'
run: |
# Configure the agent to allow default passwords
HOMEDIR="$(gpgconf --list-dirs homedir)" # spellcheck-ignore-line
mkdir -p "${HOMEDIR}"
chmod 0700 "${HOMEDIR}"
echo "allow-preset-passphrase" >> "${HOMEDIR}/gpg-agent.conf"
# Create a GPG key
gpg --quick-generate-key --yes --batch --passphrase '' \
[email protected] default \
default never
# Get info about the newly created key
DATA="$(gpg --batch --with-colons --with-keygrip --list-secret-keys)"
FINGERPRINT="$(awk -F: '/^fpr:/ { print $10 ; exit }' <<< "${DATA}")" # spellcheck-ignore-line
GRIP="$(awk -F: '/^grp:/ { print $10 ; exit }' <<< "${DATA}")"
# Save the password
gpg-connect-agent --verbose "PRESET_PASSPHRASE ${GRIP} -1 00" /bye
# Initialize pass
pass init "${FINGERPRINT}"
- name: "Windows: Stop unwanted services"
if: runner.os == 'Windows'
run: >-
Get-Service -ErrorAction Continue -Name
@('W3SVC', 'docker')
| Stop-Service
- name: "Windows: Update any pre-installed WSL"
if: runner.os == 'Windows'
run: wsl --update
continue-on-error: true
- name: "Windows: Install WSL2 from the Store as necessary"
if: runner.os == 'Windows'
run: wsl --install --no-distribution
- run: wsl --version
if: runner.os == 'Windows'
- name: "macOS: Set startup command"
if: runner.os == 'macOS'
Expand Down Expand Up @@ -114,7 +71,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: '18.16.x'
- run: npm install --global yarn
- run: corepack enable yarn
- uses: actions/setup-node@v4
with:
node-version: '18.16.x'
Expand All @@ -126,6 +83,7 @@ jobs:
with:
go-version: '^1.21'
cache-dependency-path: src/go/**/go.sum
- 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
Expand Down
48 changes: 2 additions & 46 deletions .github/workflows/smoke-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,34 +101,8 @@ jobs:
with:
persist-credentials: false

- name: "Linux: Enable KVM access"
if: runner.os == 'Linux'
run: sudo chmod a+rwx /dev/kvm

- name: "Linux: Initialize pass"
if: runner.os == 'Linux'
run: |
# Configure the agent to allow default passwords
HOMEDIR="$(gpgconf --list-dirs homedir)" # spellcheck-ignore-line
mkdir -p "${HOMEDIR}"
chmod 0700 "${HOMEDIR}"
echo "allow-preset-passphrase" >> "${HOMEDIR}/gpg-agent.conf"
# Create a GPG key
gpg --quick-generate-key --yes --batch --passphrase '' \
[email protected] default \
default never
# Get info about the newly created key
DATA="$(gpg --batch --with-colons --with-keygrip --list-secret-keys)"
FINGERPRINT="$(awk -F: '/^fpr:/ { print $10 ; exit }' <<< "${DATA}")" # spellcheck-ignore-line
GRIP="$(awk -F: '/^grp:/ { print $10 ; exit }' <<< "${DATA}")"
# Save the password
gpg-connect-agent --verbose "PRESET_PASSPHRASE ${GRIP} -1 00" /bye
# Initialize pass
pass init "${FINGERPRINT}"
- name: Set up environment
uses: ./.github/actions/setup-environment

- name: "Linux: Set startup command"
if: runner.os == 'Linux'
Expand All @@ -138,24 +112,6 @@ jobs:
exec xvfb-run --auto-servernum
--server-args='-screen 0 1280x960x24'
- name: "Windows: Stop unwanted services"
if: runner.os == 'Windows'
run: >-
Get-Service -ErrorAction Continue -Name
@('W3SVC', 'docker')
| Stop-Service
- name: "Windows: Update any pre-installed WSL"
if: runner.os == 'Windows'
run: wsl --update
continue-on-error: true

- name: "Windows: Set default WSL version"
if: runner.os == 'Windows'
run: |
wsl --set-default-version 2
wsl --version
- name: "Windows: Install yq"
if: runner.os == 'Windows'
run: |
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/windows-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,16 @@ jobs:
timeout-minutes: 90
runs-on: windows-latest
steps:
- name: Update any pre-installed WSL
run: wsl --update
continue-on-error: true
- name: Install WSL2 from the Store as necessary
run: wsl --install --no-distribution
- run: wsl --version
- name: Stop Docker daemon
run: Stop-Service -Name docker
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: ./.github/actions/setup-environment
# 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: '18.16.x'
- run: npm install --global yarn
- run: corepack enable yarn
- uses: actions/setup-node@v4
with:
node-version: '18.16.x'
Expand Down

0 comments on commit 2ee7c23

Please sign in to comment.