Skip to content

Commit

Permalink
ci: save ci time
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Jul 18, 2020
1 parent 7a8186f commit 1994e5c
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 16 deletions.
120 changes: 111 additions & 9 deletions .github/workflows/build-x86-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,20 @@ jobs:
uses: actions/checkout@v2

- name: Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v1.4.0
uses: crazy-max/ghaction-docker-buildx@v3

- name: Go mod cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go

- name: Cache Docker layers
uses: actions/cache@v2
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx

- name: Unit test
run: |
Expand All @@ -42,28 +55,117 @@ jobs:
run: |
go get -u github.com/securego/gosec/cmd/gosec
make release
make tar
- name: Security Scan
run: |
sudo apt-get install wget apt-transport-https gnupg lsb-release
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy
make scan
- name: Upload image to artifact
uses: actions/upload-artifact@v2
with:
name: image
path: image.tar

singlee2e:
needs: build
name: 1-master-e2e
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Init Kind
run: |
pip install j2cli --user
pip install "j2cli[yaml]" --user
sudo PATH=~/.local/bin:$PATH make kind-init
- name: Download image
uses: actions/download-artifact@v2
with:
name: image

- name: Install Kube-OVN
run: |
docker load --input image.tar
sudo make kind-install
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go

- name: Run E2E
run: |
go get -u github.com/onsi/ginkgo/ginkgo
go get -u github.com/onsi/gomega/...
sudo kubectl cluster-info
sudo chmod 666 /home/runner/.kube/config
make e2e
hae2e:
needs: build
name: 3-master-e2e
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Init Kind
run: |
pip install j2cli --user
pip install "j2cli[yaml]" --user
sudo PATH=~/.local/bin:$PATH make kind-init-ha
- name: Download image
uses: actions/download-artifact@v2
with:
name: image

- name: Install Kube-OVN
run: |
docker load --input image.tar
sudo make kind-install
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go

- name: Run E2E
run: |
go get -u github.com/onsi/ginkgo/ginkgo
go get -u github.com/onsi/gomega/...
sudo kubectl cluster-info
sudo chmod 666 /home/runner/.kube/config
make e2e
push:
needs: [singlee2e, hae2e]
name: push
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Download image
uses: actions/download-artifact@v2
with:
name: image

- name: Load Image
run: |
docker load --input image.tar
- name: Security Scan
run: |
sudo apt-get install wget apt-transport-https gnupg lsb-release
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy
make scan
- name: Push
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'release') }}
env:
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARCH=amd64
# RPM_ARCH could be x86_64,aarch64
RPM_ARCH=x86_64

.PHONY: build-dev-images build-go build-bin lint kind-init kind-init-ha kind-reload push-dev push-release e2e ut
.PHONY: build-dev-images build-go build-bin lint kind-init kind-init-ha kind-install kind-reload push-dev push-release e2e ut

build-dev-images: build-bin
docker build -t ${REGISTRY}/kube-ovn:${DEV_TAG} -f dist/images/Dockerfile dist/images/
Expand All @@ -35,11 +35,14 @@ build-go-arm:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(PWD)/dist/images/kube-ovn-speaker -ldflags "-w -s" -v ./cmd/speaker

release: lint build-go
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 --build-arg RPM_ARCH=x86_64 -t ${REGISTRY}/kube-ovn:${RELEASE_TAG} -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" --platform linux/amd64 --build-arg ARCH=amd64 --build-arg RPM_ARCH=x86_64 -t ${REGISTRY}/kube-ovn:${RELEASE_TAG} -o type=docker -f dist/images/Dockerfile dist/images/

release-arm: lint build-go-arm
docker buildx build --platform linux/arm64 --build-arg ARCH=arm64 --build-arg RPM_ARCH=aarch64 -t ${REGISTRY}/kube-ovn:${RELEASE_TAG} -o type=docker -f dist/images/Dockerfile dist/images/

tar:
docker save ${REGISTRY}/kube-ovn:${RELEASE_TAG} > image.tar

push-release: release
docker push ${REGISTRY}/kube-ovn:${RELEASE_TAG}

Expand All @@ -62,6 +65,8 @@ kind-init:
kind delete cluster --name=kube-ovn
ip_family=ipv4 ha=false j2 yamls/kind.yaml.j2 -o yamls/kind.yaml
kind create cluster --config yamls/kind.yaml --name kube-ovn

kind-install:
kind load docker-image --name kube-ovn ${REGISTRY}/kube-ovn:${RELEASE_TAG}
kubectl taint node kube-ovn-control-plane node-role.kubernetes.io/master:NoSchedule-
bash dist/images/install.sh
Expand All @@ -70,9 +75,6 @@ kind-init-ha:
kind delete cluster --name=kube-ovn
ip_family=ipv4 ha=true j2 yamls/kind.yaml.j2 -o yamls/kind.yaml
kind create cluster --config yamls/kind.yaml --name kube-ovn
kind load docker-image --name kube-ovn ${REGISTRY}/kube-ovn:${RELEASE_TAG}
kubectl taint node kube-ovn-control-plane node-role.kubernetes.io/master:NoSchedule-
bash dist/images/install.sh

kind-reload:
kind load docker-image --name kube-ovn ${REGISTRY}/kube-ovn:${RELEASE_TAG}
Expand Down
2 changes: 0 additions & 2 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,6 @@ spec:
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: HW_OFFLOAD
value: "$HW_OFFLOAD"
volumeMounts:
- mountPath: /lib/modules
name: host-modules
Expand Down
1 change: 1 addition & 0 deletions dist/images/start-ovs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set -euo pipefail

DB_SB_PORT=${DB_SB_PORT:-false}
# https://bugs.launchpad.net/neutron/+bug/1776778
if grep -q "3.10.0-862" /proc/version
then
Expand Down

0 comments on commit 1994e5c

Please sign in to comment.