This is an automated email from the ASF dual-hosted git repository. ocket8888 pushed a commit to tag v1 in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 3f30f77510d7ef87f617b4b29536a33211f8d76c Author: ocket8888 <[email protected]> AuthorDate: Wed Oct 30 10:53:14 2019 -0600 Set actions to run go tests --- .github/actions/go-test/Dockerfile | 5 +++++ .github/actions/go-test/README.md | 25 +++++++++++++++++++++++++ .github/actions/go-test/action.yml | 17 +++++++++++++++++ .github/actions/go-test/entrypoint.sh | 7 +++++++ .github/workflows/main.yml | 17 +++++++++++++---- 5 files changed, 67 insertions(+), 4 deletions(-) diff --git a/.github/actions/go-test/Dockerfile b/.github/actions/go-test/Dockerfile new file mode 100644 index 0000000000..a6793a7b2d --- /dev/null +++ b/.github/actions/go-test/Dockerfile @@ -0,0 +1,5 @@ +FROM golang:latest + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT /entrypoint.sh diff --git a/.github/actions/go-test/README.md b/.github/actions/go-test/README.md new file mode 100644 index 0000000000..b420b3f65e --- /dev/null +++ b/.github/actions/go-test/README.md @@ -0,0 +1,25 @@ +# go-test Docker action + +This action runs Go unit tests. + +## Inputs + +### `dir` + +**Required** Directory in which to run tests. + +## Outputs + +### `result` + +Test results. + +### `exit-code` + +Exit code of the test command + +## Example usage + +uses: actions/go-test@v1 +with: + dir: './lib/...' diff --git a/.github/actions/go-test/action.yml b/.github/actions/go-test/action.yml new file mode 100644 index 0000000000..55e1e2411b --- /dev/null +++ b/.github/actions/go-test/action.yml @@ -0,0 +1,17 @@ +name: 'go-test' +description: 'Runs go tests' +inputs: + dir: # id of input + description: 'Directory in which to run tests' + required: true +outputs: + result: # id of output + description: 'Test results' + exit-code: + description: 'Exit code of the test command' +runs: + using: 'docker' + image: 'Dockerfile' + args: + - -v + - ${{ inputs.dir }} diff --git a/.github/actions/go-test/entrypoint.sh b/.github/actions/go-test/entrypoint.sh new file mode 100644 index 0000000000..52103b9eae --- /dev/null +++ b/.github/actions/go-test/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh -l + +output=$(go test $@ 2>&1) +code=$? + +echo ::set-output name=result::$output +echo ::set-output name=exit-code::$code diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 35d1795245..22bdb19d28 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,9 +5,18 @@ on: [push] jobs: build: - runs-on: golang-latest + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Run a one-line script - run: go test -v lib/... + - name: Checkout + uses: actions/checkout@v1 + - uses: ./.github/actions/go-test/ + - name: Go test step + id: gotest + uses: ocket8888/trafficcontrol/.github/actions/go-test@v1 + with: + dir: ./lib/... + - name: Get the results + run: echo "${{ steps.gotest.outputs.result }}" + - name: Print exit code + run: echo "Exited with code ${{ steps.gotest.outputs.exit-code }}"
