-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We have multiple github actions that run e2e tests and share a significant amount of logic. We'll add reusable actions, making the workflows much easier to maintain.
- Loading branch information
1 parent
50bc0b9
commit 340cea5
Showing
10 changed files
with
345 additions
and
307 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,51 @@ | ||
name: Build k8s-snap | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
flavor: | ||
description: k8s-snap flavor (e.g. moonray or strict) | ||
type: string | ||
outputs: | ||
snap-artifact: | ||
description: Name of the uploaded snap artifact | ||
value: ${{ jobs.build-snap.outputs.snap-artifact }} | ||
|
||
jobs: | ||
build-snap: | ||
name: Build snap | ||
runs-on: ubuntu-20.04 | ||
outputs: | ||
snap-artifact: ${{ steps.build.outputs.snap-artifact }} | ||
steps: | ||
- name: Checking out repo | ||
uses: actions/checkout@v4 | ||
- name: Apply patches | ||
if: ${{ inputs.flavor }} != "" | ||
run: | | ||
./build-scripts/patches/${{ inputs.flavor }}/apply | ||
- name: Install lxd | ||
uses: ./.github/workflows/install-lxd.yaml | ||
- name: Install snapcraft | ||
run: | | ||
sudo snap install snapcraft --classic | ||
- name: Build snap | ||
id: build | ||
env: | ||
flavor: ${{ inputs.flavor }} | ||
run: | | ||
if [[ -n "$flavor" ]]; then | ||
out_snap=k8s-$flavor.snap | ||
else | ||
out_snap=k8s.snap | ||
fi | ||
sg lxd -c 'snapcraft --use-lxd' | ||
mv k8s_*.snap $out_snap | ||
echo "snap-artifact=$out_snap" >> "$GITHUB_OUTPUT" | ||
- name: Uploading snap | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ steps.build.outputs.snap-artifact }} | ||
path: ${{ steps.build.outputs.snap-artifact }} |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Download k8s-snap | ||
|
||
inputs: | ||
# Download k8s-snap using either a GH action artifact or a snap channel. | ||
artifact: | ||
description: The name of a GH action artifact. | ||
type: string | ||
channel: | ||
description: k8s snap channel. | ||
type: string | ||
output-file: | ||
description: The *.snap destination path. | ||
type: string | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Exit if no input provided | ||
if: ${{ inputs.artifact }} == '' && ${{ inputs.channel }} == '' | ||
run: | | ||
echo "No k8s-snap artifact or channel specified..." | ||
exit 1 | ||
- name: Exit if multiple inputs provided | ||
if: ${{ inputs.artifact }} != '' && ${{ inputs.channel }} != '' | ||
run: | | ||
echo "Received snap artifact AND snap channel." | ||
exit 1 | ||
- name: Create destination dir. | ||
run: mkdir -p $(dirname ${{ inputs.output-file }}) | ||
|
||
- name: Download snap artifact | ||
if: ${{ inputs.artifact }} != '' | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.artifact }} | ||
path: ${{ github.workspace }} | ||
- name: Move snap artifact. | ||
if: ${{ inputs.artifact }} != '' | ||
run: mv ${{ github.workspace }}/${{ inputs.artifact }} ${{ inputs.output-file }} | ||
|
||
- name: Download snap channel | ||
if: ${{ inputs.artifact }} != '' | ||
run: | | ||
cd $(dirname ${{ inputs.output-file }}) | ||
snap download k8s --channel=${{ inputs.channel }} --basename k8s | ||
mv k8s.snap ${{ inputs.output-file }} |
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,36 @@ | ||
name: Get e2e test tags | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
test-tags: | ||
description: The filter tags to use when running e2e tests | ||
value: ${{ jobs.get-tags.outputs.test-tags }} | ||
|
||
jobs: | ||
get-tags: | ||
name: Build snap | ||
runs-on: ubuntu-latest | ||
outputs: | ||
test-tags: ${{ steps.get-tags.outputs.snap-artifact }} | ||
steps: | ||
- name: Checking out repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build snap | ||
id: get-tags | ||
run: | | ||
tags="pull_request" | ||
if ${{ github.event_name == 'pull_request' }}; then | ||
# Run all tests if there are test changes. In case of a PR, we'll | ||
# get a merge commit that includes all changes. | ||
if git diff HEAD HEAD~1 --name-only | grep "tests/"; then | ||
tags="up_to_weekly" | ||
fi | ||
# Run all tests on backports. | ||
if echo ${{ github.base_ref }} | grep "release-"; then | ||
tags="up_to_weekly" | ||
fi | ||
fi | ||
echo "test-tags=$tags" >> "$GITHUB_OUTPUT" |
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,17 @@ | ||
name: Install lxd | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install lxd snap | ||
run: | | ||
sudo snap refresh lxd --channel 5.21/stable | ||
- name: Initialize lxd | ||
run: | ||
sudo lxd init --auto | ||
sudo usermod --append --groups lxd $USER | ||
sg lxd -c 'lxc version' | ||
- name: Apply Docker iptables workaround | ||
run: | ||
sudo iptables -I DOCKER-USER -i lxdbr0 -j ACCEPT | ||
sudo iptables -I DOCKER-USER -o lxdbr0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT |
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
Oops, something went wrong.