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 86b6ee0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 43 deletions.
49 changes: 17 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,24 @@ 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: Check auto-generated files
run: make check-generate

- name: Build sabakan image
run: docker build -t quay.io/cybozu/sabakan:latest ./docker
- name: Run code check tools
run: make code-check

- name: Save Image
run: |
mkdir -p /tmp/docker
docker save quay.io/cybozu/sabakan:latest -o /tmp/docker/image
- name: Build binaries
run: make build

- 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
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

0 comments on commit 86b6ee0

Please sign in to comment.