-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 build(plugin): Add github action (#32)
Signed-off-by: Mriyam Tamuli <mbtamuli@gmail.com>
- Loading branch information
Showing
8 changed files
with
161 additions
and
35 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,47 @@ | ||
name: emptydirclone-e2e-tests | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
permissions: | ||
actions: read | ||
packages: write | ||
|
||
jobs: | ||
build-image: | ||
uses: ./.github/workflows/image-build-push.yaml | ||
secrets: inherit | ||
e2e-tests: | ||
runs-on: ubuntu-latest | ||
needs: build-image | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
- | ||
name: Run tests | ||
working-directory: ./emptyDirClone | ||
run: | | ||
echo "Using tag: ${{ needs.build-image.outputs.tag }}" | ||
sed -i "s/emptydirclone:.*/emptydirclone:${{ needs.build-image.outputs.tag }}/" deploy/daemonset.yaml | ||
make e2e E2E_TEST_ARGS="--fail-fast --v 6" | ||
- | ||
name: Upload logs | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: e2e-logs | ||
path: ./emptyDirClone/tests/e2e/logs/ | ||
- | ||
name: Cleanup | ||
if: always() | ||
run: | | ||
for i in $(kind get clusters); do kind delete cluster --name $i; done |
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,67 @@ | ||
name: image-build-push | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
tag: | ||
description: "Container image tag" | ||
value: ${{ jobs.image-build-push.outputs.tag }} | ||
|
||
permissions: | ||
packages: write | ||
|
||
jobs: | ||
image-build-push: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tag: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} | ||
steps: | ||
- | ||
name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/mbtamuli/csi-quickstart/emptydirclone | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
platforms: linux/amd64,linux/arm64 | ||
- | ||
name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- | ||
name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: "{{defaultContext}}:emptyDirClone" | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
build-args: | ||
VERSION=${{ github.sha }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | ||
- # Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
# syntax=docker/dockerfile:1 | ||
FROM golang:1.21 as builder | ||
ARG GO_VERSION=1.21 | ||
ARG VERSION | ||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} as builder | ||
|
||
WORKDIR /app | ||
WORKDIR /src | ||
|
||
RUN --mount=source=go.mod,target=go.mod \ | ||
--mount=source=go.sum,target=go.sum \ | ||
--mount=type=cache,target=/go/pkg \ | ||
RUN --mount=type=cache,target=/go/pkg/mod/ \ | ||
--mount=type=bind,source=go.sum,target=go.sum \ | ||
--mount=type=bind,source=go.mod,target=go.mod \ | ||
go mod download -x | ||
|
||
RUN --mount=target=. \ | ||
ARG TARGETARCH | ||
|
||
RUN --mount=type=bind,target=. \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
CGO_ENABLED=0 GOOS=linux \ | ||
CGO_ENABLED=0 GOARCH=$TARGETARCH \ | ||
go build -ldflags "-s -w -X main.version=${VERSION}" -o /emptydirclone main.go | ||
|
||
FROM gcr.io/distroless/static-debian12:debug as debug | ||
COPY --from=builder /emptydirclone /emptydirclone | ||
ENTRYPOINT ["/emptydirclone"] | ||
|
||
FROM gcr.io/distroless/static-debian12 as final | ||
FROM alpine | ||
# Add util-linux to get a new version of losetup. | ||
RUN apk update && apk upgrade && apk add util-linux coreutils | ||
COPY --from=builder /emptydirclone /emptydirclone | ||
ENTRYPOINT ["/emptydirclone"] |
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
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
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