Files
sealos/.github/workflows/import-patch-image.yml
T
cuisongliu c8d475710a docs(main): add e2e test images (#3013)
Signed-off-by: cuisongliu <cuisongliu@qq.com>
2023-04-28 14:36:06 +08:00

183 lines
5.1 KiB
YAML
Executable File

name: Patch Images Package
env:
# Common versions
GO_VERSION: "1.20"
on:
workflow_call:
inputs:
e2e:
required: false
type: boolean
default: false
arch:
required: true
type: string
default: amd64
image:
required: false
type: boolean
default: true
jobs:
resolve-modules-arch:
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Resolve Modules
id: set-matrix
run: bash ./scripts/resolve-patch-modules.sh ${{ inputs.arch }} "true"
resolve-modules:
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Resolve Modules
id: set-matrix
run: bash ./scripts/resolve-patch-modules.sh ${{ inputs.arch }}
build:
needs: [ resolve-modules ]
runs-on: ubuntu-20.04
strategy:
matrix: ${{ fromJson(needs.resolve-modules.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Dependencies
run: sudo apt update && sudo apt install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- name: Install Dependencies
if: ${{ (matrix.binary == 'sealos' || matrix.binary == 'sealctl') && matrix.arch == 'arm64' }}
run: |
sudo apt update && sudo apt install -y gcc-aarch64-linux-gnu
- name: Build Binaries
run: |
make build BINS=${{ matrix.binary }} PLATFORM=linux_${{ matrix.arch }}
- name: Save Binaries
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.binary }}-${{ matrix.arch }}
path: bin/linux_${{ matrix.arch}}/${{ matrix.binary }}
test:
runs-on: ubuntu-20.04
if: ${{ (inputs.e2e == true) }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Dependencies
run: sudo apt update && sudo apt install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- name: Build E2e Test
run: |
go install github.com/onsi/ginkgo/v2/ginkgo
cd test/e2e && ginkgo build .
- name: Save E2e Test
uses: actions/upload-artifact@v3
with:
name: e2e.test
path: test/e2e/e2e.test
docker:
needs: [ resolve-modules-arch,build ]
runs-on: ubuntu-20.04
if: ${{ (inputs.image == true) }}
services:
registry:
image: registry:2
ports:
- 5000:5000
strategy:
matrix: ${{ fromJson(needs.resolve-modules-arch.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Expose git commit data
uses: rlespinasse/git-commit-data-action@v1
- name: Download lvscare
uses: actions/download-artifact@v3
with:
name: lvscare-${{ matrix.arch }}
path: docker/lvscare
- name: Download sealctl
uses: actions/download-artifact@v3
with:
name: sealctl-${{ matrix.arch }}
path: docker/patch
- name: Download image-cri-shim
uses: actions/download-artifact@v3
with:
name: image-cri-shim-${{ matrix.arch }}
path: docker/patch
- name: Download sealos
uses: actions/download-artifact@v3
with:
name: sealos-${{ matrix.arch }}
path: docker/sealos
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host
- name: Chmod a+x for docker
run: |
chmod a+x docker/sealos/*
chmod a+x docker/patch/*
chmod a+x docker/lvscare/*
- name: Build and Push lvscare Image
uses: docker/build-push-action@v3
with:
context: docker/lvscare
file: docker/lvscare/Dockerfile.main
push: true
build-args: Bin=lvscare
platforms: linux/${{ matrix.arch }}
tags: localhost:5000/${{ github.repository_owner }}/lvscare:${{ env.GIT_COMMIT_SHORT_SHA }}-${{ matrix.arch }}
- name: Build and Save Cluster Images
run: docker/patch/save-cluster-images.sh
env:
ARCH: ${{ matrix.arch }}
OWNER: ${{ github.repository_owner }}
- name: Upload Cluster Images
uses: actions/upload-artifact@v3
with:
name: patch-image-${{ matrix.arch }}.tar
path: patch-${{ matrix.arch }}.tar
- name: Delete Artifacts
uses: geekyeggo/delete-artifact@v1
with:
name: |
lvscare-${{ matrix.arch }}
sealctl-${{ matrix.arch }}
image-cri-shim-${{ matrix.arch }}
failOnError: false