-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6778 from mook-as/ci/setup-for-run
CI: Use shared steps for setting up environment
- Loading branch information
Showing
7 changed files
with
79 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,7 @@ containo | |
copypac | ||
coredns | ||
corejs | ||
corepack | ||
coreutils | ||
crd | ||
credfwd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
|
@@ -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' | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
|
@@ -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: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters