Skip to content

Commit

Permalink
build: use docker api version 1.43 when testing in GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
plaffitt committed May 3, 2024
1 parent 11c3ba4 commit ff401cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
runs-on: ubuntu-22.04
env:
ENVTEST_K8S_VERSION: ${{ matrix.kubernetes-version }}
DOCKER_CLIENT_API_VERSION: '1.43' # 1.45 is not supported by ubuntu-22.04 GitHub image
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ jobs:
tests:
name: Tests
runs-on: ubuntu-22.04
env:
DOCKER_CLIENT_API_VERSION: '1.43' # 1.45 is not supported by ubuntu-22.04 GitHub image
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -499,7 +501,7 @@ jobs:
run: |
from lib import *
import os
header('semantic-release job outputs')
info('last = {}'.format(os.environ['SR_LAST']))
info('published = {}'.format(os.environ['SR_PUBLISHED']))
Expand Down Expand Up @@ -563,7 +565,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache for chart-releaser
id: cache-cr
uses: actions/cache@v4
Expand Down Expand Up @@ -600,7 +602,7 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GHCR
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
Expand Down Expand Up @@ -653,7 +655,7 @@ jobs:
${{ github.repository }}:latest
${{ env.QUAY_IMAGE }}:latest
${{ env.GHCR_IMAGE }}:latest
- name: Push container images tag (Release)
uses: docker/build-push-action@v5
with:
Expand Down Expand Up @@ -766,7 +768,7 @@ jobs:
links.append({
'name': 'GitHub issue #{}'.format(issue.group('id')),
'url': issue.group('url')
})
})
entry = {
'kind': kind,
Expand Down Expand Up @@ -806,7 +808,7 @@ jobs:
run: |
from lib import *
import os, yaml, shutil
chart_path = os.path.join(os.environ['WORKSPACE'], 'repository', 'helm', 'kube-image-keeper')
os.chdir(chart_path)
Expand Down Expand Up @@ -856,7 +858,7 @@ jobs:
print(yaml.safe_load(open(yaml_file, 'r')))
header('release the chart')
action('clone helm charts repository')
charts_repo = os.path.join(os.environ['WORKSPACE'], 'enix-charts')
run('git', 'clone', 'https://github.com/enix/helm-charts', charts_repo)
Expand Down
9 changes: 5 additions & 4 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"testing"
"time"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/image"
dockerClient "github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -39,6 +39,7 @@ var testEnv *envtest.Environment
var ctx context.Context
var cancel context.CancelFunc
var registryContainerId string
var dockerClientApiVersion = os.Getenv("DOCKER_CLIENT_API_VERSION")

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)
Expand All @@ -47,12 +48,12 @@ func TestAPIs(t *testing.T) {
}

func setupRegistry() {
client, err := dockerClient.NewClientWithOpts(dockerClient.FromEnv)
client, err := dockerClient.NewClientWithOpts(dockerClient.FromEnv, dockerClient.WithVersion(dockerClientApiVersion))
Expect(err).NotTo(HaveOccurred())

// Pull image
ctx := context.Background()
reader, err := client.ImagePull(ctx, "registry", types.ImagePullOptions{})
reader, err := client.ImagePull(ctx, "registry", image.PullOptions{})
Expect(err).NotTo(HaveOccurred())
_, err = io.Copy(os.Stdout, reader)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -93,7 +94,7 @@ func setupRegistry() {
}

func removeRegistry() {
client, err := dockerClient.NewClientWithOpts(dockerClient.FromEnv)
client, err := dockerClient.NewClientWithOpts(dockerClient.FromEnv, dockerClient.WithVersion(dockerClientApiVersion))
Expect(err).NotTo(HaveOccurred())

err = client.ContainerRemove(context.Background(), registryContainerId, container.RemoveOptions{
Expand Down

0 comments on commit ff401cb

Please sign in to comment.