From d46be324e560a66e5940750d8a0e41174cad3c5c Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 15 Apr 2021 00:19:17 -0700 Subject: [PATCH 1/3] tests: improve bats/gh integration Signed-off-by: Andrea Luzzardi --- .github/workflows/ci.yml | 8 ++++++++ .gitignore | 1 + tests/helpers.bash | 3 +++ tests/package.json | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e89b65e7..21bad162 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,3 +76,11 @@ jobs: - name: Integration test run: | make integration + + - name: Publish Test Report + uses: mikepenz/action-junit-report@v2 + if: always() + with: + report_paths: "tests/*.xml" + github_token: ${{ secrets.GITHUB_TOKEN }} + check_name: "Test Report" diff --git a/.gitignore b/.gitignore index 48558707..1244af75 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ # Test binary, build with `go test -c` *.test +tests/report.xml # Output of the go coverage tool, specifically when used with LiteIDE *.out diff --git a/tests/helpers.bash b/tests/helpers.bash index 8d52cd0a..60bfb9e3 100644 --- a/tests/helpers.bash +++ b/tests/helpers.bash @@ -7,6 +7,9 @@ common_setup() { DAGGER="${DAGGER_BINARY:-$TESTDIR/../cmd/dagger/dagger}" export DAGGER + DAGGER_LOG_FORMAT="pretty" + export DAGGER_LOG_FORMAT + DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" export DAGGER_STORE } diff --git a/tests/package.json b/tests/package.json index f6177bd6..4af287e6 100644 --- a/tests/package.json +++ b/tests/package.json @@ -1,7 +1,7 @@ { "license": "Apache-2.0", "scripts": { - "test": "bats ." + "test": "bats --report-formatter junit ." }, "devDependencies": { "bats": "https://github.com/bats-core/bats-core.git", From 23d6a8800b8eb18953deccfe2cc7fcc401a1676e Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 15 Apr 2021 00:55:01 -0700 Subject: [PATCH 2/3] tests: split unit and integration Signed-off-by: Andrea Luzzardi --- .github/workflows/ci.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21bad162..205120ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,23 @@ jobs: name: Test runs-on: ubuntu-latest timeout-minutes: 30 + steps: + - name: Check out + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.16 + + - name: Test + run: | + make test + + integration: + name: Integration + runs-on: ubuntu-latest + timeout-minutes: 30 steps: - name: Check out uses: actions/checkout@v2 @@ -69,10 +86,6 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Test - run: | - make test - - name: Integration test run: | make integration @@ -83,4 +96,4 @@ jobs: with: report_paths: "tests/*.xml" github_token: ${{ secrets.GITHUB_TOKEN }} - check_name: "Test Report" + check_name: "Report" From 3f9103c8aad311f974f1657ccc12354b1ea400f7 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 15 Apr 2021 01:15:01 -0700 Subject: [PATCH 3/3] buildkit: support concurrent starts Signed-off-by: Andrea Luzzardi --- pkg/buildkitd/buildkitd.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pkg/buildkitd/buildkitd.go b/pkg/buildkitd/buildkitd.go index e3b93f82..f6effa61 100644 --- a/pkg/buildkitd/buildkitd.go +++ b/pkg/buildkitd/buildkitd.go @@ -116,13 +116,18 @@ func startBuildkit(ctx context.Context) error { ) output, err = cmd.CombinedOutput() if err != nil { - log. - Ctx(ctx). - Error(). - Err(err). - Bytes("output", output). - Msg("unable to start buildkitd") - return err + // If the daemon failed to start because it's already running, + // chances are another dagger instance started it. We can just ignore + // the error. + if !strings.Contains(string(output), "Error response from daemon: Conflict.") { + log. + Ctx(ctx). + Error(). + Err(err). + Bytes("output", output). + Msg("unable to start buildkitd") + return err + } } return waitBuildkit(ctx) }