Merge pull request #329 from dagger/bats-gh-action

tests: improve bats/gh integration
This commit is contained in:
Andrea Luzzardi 2021-04-15 01:25:19 -07:00 committed by GitHub
commit 0f22f07c3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 12 deletions

View File

@ -42,6 +42,23 @@ jobs:
name: Test name: Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 30 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: steps:
- name: Check out - name: Check out
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -69,10 +86,14 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Test
run: |
make test
- name: Integration test - name: Integration test
run: | run: |
make integration 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: "Report"

1
.gitignore vendored
View File

@ -12,6 +12,7 @@
# Test binary, build with `go test -c` # Test binary, build with `go test -c`
*.test *.test
tests/report.xml
# Output of the go coverage tool, specifically when used with LiteIDE # Output of the go coverage tool, specifically when used with LiteIDE
*.out *.out

View File

@ -116,13 +116,18 @@ func startBuildkit(ctx context.Context) error {
) )
output, err = cmd.CombinedOutput() output, err = cmd.CombinedOutput()
if err != nil { if err != nil {
log. // If the daemon failed to start because it's already running,
Ctx(ctx). // chances are another dagger instance started it. We can just ignore
Error(). // the error.
Err(err). if !strings.Contains(string(output), "Error response from daemon: Conflict.") {
Bytes("output", output). log.
Msg("unable to start buildkitd") Ctx(ctx).
return err Error().
Err(err).
Bytes("output", output).
Msg("unable to start buildkitd")
return err
}
} }
return waitBuildkit(ctx) return waitBuildkit(ctx)
} }

View File

@ -7,6 +7,9 @@ common_setup() {
DAGGER="${DAGGER_BINARY:-$TESTDIR/../cmd/dagger/dagger}" DAGGER="${DAGGER_BINARY:-$TESTDIR/../cmd/dagger/dagger}"
export DAGGER export DAGGER
DAGGER_LOG_FORMAT="pretty"
export DAGGER_LOG_FORMAT
DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)"
export DAGGER_STORE export DAGGER_STORE
} }

View File

@ -1,7 +1,7 @@
{ {
"license": "Apache-2.0", "license": "Apache-2.0",
"scripts": { "scripts": {
"test": "bats ." "test": "bats --report-formatter junit ."
}, },
"devDependencies": { "devDependencies": {
"bats": "https://github.com/bats-core/bats-core.git", "bats": "https://github.com/bats-core/bats-core.git",