Skip to content

Commit

Permalink
feat: add job-url to metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta committed Aug 17, 2023
1 parent 6303b3f commit ec058b3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion cmd/gateway-conformance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).",
Expand All @@ -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()...)
Expand Down
1 change: 1 addition & 0 deletions tests/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

func TestMetadata(t *testing.T) {
tooling.LogVersion(t)
tooling.LogJobURL(t)
}

const (
Expand Down
1 change: 1 addition & 0 deletions tooling/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

var (
Version = "dev"
JobURL = ""
)

func Home() string {
Expand Down
8 changes: 8 additions & 0 deletions tooling/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

0 comments on commit ec058b3

Please sign in to comment.