-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a unit test workflow and restructures the github workflows so that we run golangci-lint and unit tests first. Only when they have succeded will the pipeline continue with e2e tests. The goal is to conserve resources and avoid running pointless jobs. The commit also removes unnecessary permissions and avoids running the jobs if the PR is a draft. Signed-off-by: Lennart Jern <lennart.jern@est.tech>
- Loading branch information
Showing
5 changed files
with
133 additions
and
14 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
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,53 @@ | ||
name: E2E Test | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
bmc-protocol: | ||
required: true | ||
type: string | ||
runner: | ||
type: string | ||
default: "ubuntu-latest-4-cores" | ||
ginkgo-focus: | ||
type: string | ||
default: "" | ||
ref: | ||
type: string | ||
default: ${{ github.ref }} | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
test: | ||
name: E2E test | ||
runs-on: ${{ inputs.runner }} | ||
|
||
steps: | ||
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
|
||
- name: Install libvirt | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y libvirt-daemon-system qemu-kvm virt-manager | ||
- name: Run BMO e2e Tests | ||
env: | ||
BMC_PROTOCOL: ${{ inputs.bmc-protocol }} | ||
GINKGO_FOCUS: "${{ inputs.ginkgo-focus }}" | ||
# We need a new shell to pick up the new group. That is why we do the sudo -s -u $USER ... | ||
# Remove the pre-installed go version. We install the exact version we need. | ||
run: | | ||
sudo usermod -a -G libvirt $USER | ||
sudo rm /usr/bin/go | ||
sudo -s -u $USER --preserve-env bash ${{ github.workspace }}/hack/ci-e2e.sh | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | ||
with: | ||
name: artifacts-${{ inputs.bmc-protocol }}.tar.gz | ||
path: test/e2e/_artifacts | ||
if-no-files-found: error | ||
overwrite: false |
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,44 @@ | ||
name: E2E Test pipeline | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize, reopened, ready_for_review] | ||
branches: | ||
- 'main' | ||
- 'release-*' | ||
paths-ignore: | ||
- '**/*.md' | ||
- 'docs/**' | ||
- '.gitignore' | ||
- 'LICENSE' | ||
- 'SECURITY_CONTACTS' | ||
- 'DCO' | ||
- 'OWNERS' | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
golangci-lint: | ||
if: github.event.pull_request.draft == false | ||
uses: ./.github/workflows/golangci-lint.yml | ||
|
||
unit: | ||
if: github.event.pull_request.draft == false | ||
uses: ./.github/workflows/unit.yml | ||
|
||
e2e-fixture-test: | ||
needs: [golangci-lint, unit] | ||
uses: ./.github/workflows/e2e-fixture-test.yml | ||
|
||
e2e-test: | ||
needs: [golangci-lint, unit] | ||
strategy: | ||
# Avoid wasting CI resources | ||
fail-fast: true | ||
matrix: | ||
bmc-protocol: | ||
- redfish-virtualmedia | ||
- ipmi | ||
uses: ./.github/workflows/e2e-test.yml | ||
with: | ||
bmc-protocol: ${{ matrix.bmc-protocol }} |
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,25 @@ | ||
name: unit | ||
|
||
on: | ||
workflow_call: | ||
|
||
# Remove all permissions from GITHUB_TOKEN except metadata. | ||
permissions: {} | ||
|
||
jobs: | ||
golangci: | ||
name: unit | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
- name: Calculate go version | ||
id: vars | ||
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT | ||
- name: Set up Go | ||
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 | ||
with: | ||
go-version: ${{ steps.vars.outputs.go_version }} | ||
- name: Run unit tests | ||
run: make -e unit-cover | ||
env: | ||
TEST_FLAGS: "-v" |