Skip to content

Commit

Permalink
improve CI
Browse files Browse the repository at this point in the history
Signed-off-by: YZ775 <yuzuki-mimura@cybozu.co.jp>
  • Loading branch information
YZ775 committed Oct 31, 2023
1 parent bd5fe3c commit 663f476
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 44 deletions.
43 changes: 11 additions & 32 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ env:
go-version: "1.20"
filename: 'main.yaml'
jobs:
build:
name: Build
unit-test:
name: Unit Test
runs-on: ubuntu-22.04
steps:
- name: Checkout
Expand All @@ -34,28 +34,13 @@ jobs:

- name: Build binaries
run: make build
- name: Check e2e
run: echo $RUN_E2E

- name: Run test
run: make test

- name: Prepare for uploading sabakan binaries
run: |
mkdir /tmp/workspace
cp ./sabakan ./sabactl ./sabakan-cryptsetup /tmp/workspace
cp LICENSE /tmp/workspace
- name: Upload sabakan binaries
uses: actions/upload-artifact@v3
with:
name: sabakan-binaries
path: /tmp/workspace
retention-days: 1

build-image:
name: Build Images
e2e-test:
name: e2e Test
runs-on: ubuntu-22.04
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -65,24 +50,18 @@ jobs:
with:
go-version: ${{ env.go-version }}

- name: Download sabakan binaries
uses: actions/download-artifact@v3
with:
name: sabakan-binaries
path: ./docker
- name: Install test tools
run: make SUDO="sudo" test-tools

- name: Build sabakan image
run: docker build -t quay.io/cybozu/sabakan:latest ./docker
- name: Build binaries
run: make build

- name: Save Image
run: |
mkdir -p /tmp/docker
docker save quay.io/cybozu/sabakan:latest -o /tmp/docker/image
- name: Run test
run: make e2e

mtest:
name: Multi-host test
runs-on: ubuntu-22.04
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion bin/run-mtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ git checkout -qf ${GITHUB_SHA}
cd mtest
cp /assets/etcd-*.tar.gz .
cp /assets/ubuntu-*.img .
make setup
sudo make setup
make placemat
sleep 3
exec make test TARGET="${TARGET}"
Expand Down
11 changes: 0 additions & 11 deletions e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ const (
sabakanTLSKeyFile = "./certs/server.key.insecure"
)

var ci = false

func init() {
ci = os.Getenv("CI") == "true"
}

func testMain(m *testing.M) (int, error) {
stopEtcd := runEtcd()
defer func() {
Expand Down Expand Up @@ -78,11 +72,6 @@ func runEtcd() func() {
}

func TestMain(m *testing.M) {
if ci {
code := m.Run()
os.Exit(code)
}

if len(os.Getenv("RUN_E2E")) == 0 {
os.Exit(0)
}
Expand Down
1 change: 1 addition & 0 deletions mtest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,4 @@ clean:
.PHONY: setup
setup:
go install github.com/onsi/ginkgo/v2/ginkgo
sudo make -C ../ setup-cfssl

0 comments on commit 663f476

Please sign in to comment.