Skip to content

Commit

Permalink
ci: change to use GitHub actions
Browse files Browse the repository at this point in the history
Signed-off-by: PoAn Yang <[email protected]>
  • Loading branch information
FrankYang0529 authored and innobead committed May 1, 2024
1 parent 8856b22 commit 8c54ad0
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 3 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: build
on:
push:
branches:
- master
- v*
tags:
- v*
pull_request:
jobs:
flake8:
name: flake8 check
runs-on: ubuntu-latest
container:
image: rancher/dapper:v0.6.0
steps:
- name: Checkout code
uses: actions/checkout@v4

# flake8 check
- name: Run dapper
run: dapper

build_images:
name: Build images
runs-on: ubuntu-latest
needs: flake8
steps:
- name: Checkout code
uses: actions/checkout@v4

# For multi-platform support
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# longhornio/longhorn-manager-test image
- name: Build longhorn-manager-test image
uses: docker/build-push-action@v5
with:
context: ./
push: false
platforms: linux/amd64,linux/arm64
tags: longhornio/longhorn-manager-test:dry-run
file: manager/integration/Dockerfile

# longhornio/longhorn-e2e-test image
- name: Build longhorn-e2e-test image
uses: docker/build-push-action@v5
with:
context: ./
push: false
platforms: linux/amd64,linux/arm64
tags: longhornio/longhorn-e2e-test:dry-run
file: e2e/Dockerfile

build_push_images:
name: Build and push images
runs-on: ubuntu-latest
needs: build_images
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }}
steps:
- name: Checkout code
uses: actions/checkout@v4

# For multi-platform support
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Declare branch
run: |
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# longhorn-manager-test image
- name: Build and push longhorn-manager-test image with branch head
if: ${{ startsWith(github.ref, 'refs/heads/') }}
uses: docker/build-push-action@v5
with:
context: ./
push: true
platforms: linux/amd64,linux/arm64
tags: longhornio/longhorn-manager-test:${{ env.branch }}-head
file: manager/integration/Dockerfile

- name: Build and push longhorn-manager-test image with git tag
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: docker/build-push-action@v5
with:
context: ./
push: true
platforms: linux/amd64,linux/arm64
tags: longhornio/longhorn-manager-test:${{ github.ref_name }}
file: manager/integration/Dockerfile

# longhorn-e2e-test image
- name: Build and push longhorn-e2e-test image with branch head
if: ${{ startsWith(github.ref, 'refs/heads/') }}
uses: docker/build-push-action@v5
with:
context: ./
push: true
platforms: linux/amd64,linux/arm64
tags: longhornio/longhorn-e2e-test:${{ env.branch }}-head
file: e2e/Dockerfile

- name: Build and push longhorn-e2e-test image with git tag
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: docker/build-push-action@v5
with:
context: ./
push: true
platforms: linux/amd64,linux/arm64
tags: longhornio/longhorn-e2e-test:${{ github.ref_name }}
file: e2e/Dockerfile
10 changes: 8 additions & 2 deletions e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
FROM registry.suse.com/bci/python:3.11

ARG TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ] && [ "$TARGETPLATFORM" != "linux/arm64" ]; then \
echo "Error: Unsupported TARGETPLATFORM: $TARGETPLATFORM" && \
exit 1; \
fi
ENV ARCH ${TARGETPLATFORM#linux/}

ARG KUBECTL_VERSION=v1.17.0
ARG YQ_VERSION=v4.24.2
ARG ARCH=amd64

RUN zypper ref -f
RUN zypper in -y vim-small nfs-client xfsprogs e2fsprogs util-linux-systemd gcc python311-devel gawk java-11-openjdk tar awk gzip wget && \
Expand All @@ -24,4 +30,4 @@ WORKDIR /e2e

RUN pip install -r requirements.txt

ENTRYPOINT ["./run.sh"]
ENTRYPOINT ["./run.sh"]
8 changes: 7 additions & 1 deletion manager/integration/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
FROM registry.suse.com/bci/python:3.11

ARG TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ] && [ "$TARGETPLATFORM" != "linux/arm64" ]; then \
echo "Error: Unsupported TARGETPLATFORM: $TARGETPLATFORM" && \
exit 1; \
fi
ENV ARCH ${TARGETPLATFORM#linux/}

ARG KUBECTL_VERSION=v1.28.4
ARG YQ_VERSION=v4.24.2
ARG TERRAFORM_VERSION=1.3.5
ARG ARCH=amd64

RUN zypper ref -f
RUN zypper in -y vim-small nfs-client xfsprogs e2fsprogs util-linux-systemd gcc python311-devel gawk java-11-openjdk tar awk gzip wget unzip && \
Expand Down

0 comments on commit 8c54ad0

Please sign in to comment.