Skip to content

Commit

Permalink
Clean up GitHub Action definitions
Browse files Browse the repository at this point in the history
This defines a local action for the common actions performed by most of
our workflows. This reduces duplication between them to make sure they
are consistent, and also make the workflow definitions more concise to
just the operations that are unique to the particular testing
activities.

Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
  • Loading branch information
stmcginnis committed Jun 11, 2024
1 parent dda3e5b commit d61defd
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 89 deletions.
36 changes: 36 additions & 0 deletions .github/actions/setup-env/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Setup environment"
description: "Performs common setup operations."
runs:
using: "composite"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Get go version
id: golangversion
run: |
echo "go_version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- name: Set up Go
id: go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: ${{ steps.golangversion.outputs.go_version }}
check-latest: true

- name: Install kind
run: sudo make install INSTALL_DIR=/usr/local/bin
shell: bash

- name: Install kubectl
run: |
curl -LO https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
shell: bash

- name: Enable ipv4 and ipv6 forwarding
run: |
sudo sysctl -w net.ipv6.conf.all.forwarding=1
sudo sysctl -w net.ipv4.ip_forward=1
shell: bash
29 changes: 1 addition & 28 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,7 @@ jobs:
JOB_NAME: "docker-${{ matrix.deployment }}-${{ matrix.ipFamily }}"
IP_FAMILY: ${{ matrix.ipFamily }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Get go version
id: golangversion
run: |
echo "go_version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- name: Set up Go
id: go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: ${{ steps.golangversion.outputs.go_version }}
check-latest: true

- name: Install kind
run: sudo make install INSTALL_DIR=/usr/local/bin

- name: Install kubectl
run: |
curl -LO https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
- name: Enable ipv4 and ipv6 forwarding
run: |
sudo sysctl -w net.ipv6.conf.all.forwarding=1
sudo sysctl -w net.ipv4.ip_forward=1
- uses: ./.github/actions/setup-env

- name: Create single node cluster
if: ${{ matrix.deployment == 'singleNode' }}
Expand Down
31 changes: 1 addition & 30 deletions .github/workflows/nerdctl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,7 @@ jobs:
NERDCTL_VERSION: "1.7.4"
KIND_EXPERIMENTAL_PROVIDER: "nerdctl"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: Get go version
id: golangversion
run: |
echo "go_version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- name: Set up Go
id: go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: ${{ steps.golangversion.outputs.go_version }}
check-latest: true

- name: Install kind
run: sudo make install INSTALL_DIR=/usr/local/bin

- name: Install kubectl
run: |
curl -LO https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
- name: Enable ipv4 and ipv6 forwarding
run: |
sudo sysctl -w net.ipv6.conf.all.forwarding=1
sudo sysctl -w net.ipv4.ip_forward=1
- uses: ./.github/actions/setup-env

- name: Install nerdctl
run: |
Expand Down
31 changes: 1 addition & 30 deletions .github/workflows/podman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,7 @@ jobs:
IP_FAMILY: ${{ matrix.ipFamily }}
PODMAN_VERSION: "stable"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: Get go version
id: golangversion
run: |
echo "go_version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- name: Set up Go
id: go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: ${{ steps.golangversion.outputs.go_version }}
check-latest: true

- name: Install kind
run: sudo make install INSTALL_DIR=/usr/local/bin

- name: Install kubectl
run: |
curl -LO https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
- name: Enable ipv4 and ipv6 forwarding
run: |
sudo sysctl -w net.ipv6.conf.all.forwarding=1
sudo sysctl -w net.ipv4.ip_forward=1
- uses: ./.github/actions/setup-env

- name: Setup podman
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vm.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: VM
name: CGroupv2

on:
workflow_dispatch:
Expand Down

0 comments on commit d61defd

Please sign in to comment.