diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index 8a28e771e..fbd6de167 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -40,12 +40,13 @@ runs: SUBDOMAIN: ${{ inputs.subdomain-url }} JSON: ${{ inputs.json }} SPECS: ${{ inputs.specs }} + JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} with: repository: ${{ steps.github.outputs.action_repository }} ref: ${{ steps.github.outputs.action_sha || steps.github.outputs.action_ref }} dockerfile: Dockerfile opts: --network=host - args: test --url="$URL" --json="$JSON" --specs="$SPECS" --subdomain-url="$SUBDOMAIN" -- ${{ inputs.args }} + args: test --url="$URL" --json="$JSON" --specs="$SPECS" --subdomain-url="$SUBDOMAIN" --job-url="$JOB_URL" -- ${{ inputs.args }} build-args: | VERSION:${{ steps.github.outputs.action_ref }} - name: Create the XML diff --git a/Makefile b/Makefile index 61db8800e..c32909ad8 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,10 @@ fixtures.car: gateway-conformance ./gateway-conformance extract-fixtures --merged=true --dir=. gateway-conformance: - go build -ldflags="-X github.com/ipfs/gateway-conformance/tooling.Version=$(CLI_VERSION)" -o ./gateway-conformance ./cmd/gateway-conformance + go build \ + -ldflags="-X github.com/ipfs/gateway-conformance/tooling.Version=$(CLI_VERSION)" \ + -o ./gateway-conformance \ + ./cmd/gateway-conformance test-docker: docker fixtures.car gateway-conformance ./gc test diff --git a/cmd/gateway-conformance/main.go b/cmd/gateway-conformance/main.go index dc0bd90f7..994ea8455 100644 --- a/cmd/gateway-conformance/main.go +++ b/cmd/gateway-conformance/main.go @@ -72,6 +72,7 @@ func main() { var gatewayURL string var subdomainGatewayURL string var jsonOutput string + var jobURL string var specs string var directory string var merged bool @@ -107,6 +108,13 @@ func main() { Value: "", Destination: &jsonOutput, }, + &cli.StringFlag{ + Name: "job-url", + Aliases: []string{}, + Usage: "The Job URL where this run will be visible.", + Value: "", + Destination: &jobURL, + }, &cli.StringFlag{ Name: "specs", Usage: "Accepts a spec (test only this spec), a +spec (test also this immature spec), or a -spec (do not test this mature spec).", @@ -127,7 +135,7 @@ func main() { args = append(args, fmt.Sprintf("-specs=%s", specs)) } - ldFlag := fmt.Sprintf("-ldflags=-X github.com/ipfs/gateway-conformance/tooling.Version=%s", tooling.Version) + ldFlag := fmt.Sprintf("-ldflags=-X github.com/ipfs/gateway-conformance/tooling.Version=%s -X github.com/ipfs/gateway-conformance/tooling.JobURL=%s", tooling.Version, jobURL) args = append(args, ldFlag) args = append(args, cCtx.Args().Slice()...) diff --git a/tests/metadata_test.go b/tests/metadata_test.go index 4d03bef1e..d49770676 100644 --- a/tests/metadata_test.go +++ b/tests/metadata_test.go @@ -8,6 +8,7 @@ import ( func TestMetadata(t *testing.T) { tooling.LogVersion(t) + tooling.LogJobURL(t) } const ( diff --git a/tooling/env.go b/tooling/env.go index ff888f387..a41df74a9 100644 --- a/tooling/env.go +++ b/tooling/env.go @@ -8,6 +8,7 @@ import ( var ( Version = "dev" + JobURL = "" ) func Home() string { diff --git a/tooling/metadata.go b/tooling/metadata.go index 1e1e04b8c..b9cdfb010 100644 --- a/tooling/metadata.go +++ b/tooling/metadata.go @@ -45,3 +45,11 @@ func LogVersion(t *testing.T) { Version: Version, }) } + +func LogJobURL(t *testing.T) { + LogMetadata(t, struct { + JobURL string `json:"job_url"` + }{ + JobURL: JobURL, + }) +}