forked from ChelseaKR/gtfs-scorecard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
113 lines (110 loc) · 4.19 KB
/
Copy pathaction.yml
File metadata and controls
113 lines (110 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: "GTFS Scorecard gate"
description: "Score a GTFS Schedule feed and fail the build if it falls below a grade or is about to expire."
author: "gtfs-scorecard"
branding:
icon: "check-circle"
color: "green"
outputs:
grade:
description: "Overall letter grade (A, B, C, D, or F)."
value: ${{ steps.gate.outputs.grade }}
score:
description: "Overall numeric score from 0 to 100."
value: ${{ steps.gate.outputs.score }}
days-to-expiry:
description: "Published service days remaining, or blank when unavailable."
value: ${{ steps.gate.outputs.days-to-expiry }}
passed:
description: "true when scoring and every configured threshold passed."
value: ${{ steps.gate.outputs.passed }}
result-json:
description: "Path to the complete scorecard JSON artifact for later workflow steps."
value: ${{ steps.gate.outputs.result-json }}
inputs:
feed-url:
description: "Direct link to a GTFS Schedule zip to score."
required: true
min-grade:
description: "Fail if the overall grade is below this letter (A, B, C, D, or F). Leave blank to skip the grade check."
required: false
default: ""
min-days-to-expiry:
description: "Fail if the feed expires within this many days. Leave blank to skip the expiry check."
required: false
default: ""
name:
description: "Agency name to show in the report (default: the feed host)."
required: false
default: ""
country:
description: "Assigned ISO 3166-1 alpha-2 feed country used by the validator."
required: false
default: "US"
html:
description: "Path to also write a standalone HTML scorecard (relative to the workspace). Leave blank to skip."
required: false
default: ""
json:
description: "Path for the complete scorecard JSON. Defaults to a runner temporary file."
required: false
default: ""
summary:
description: "Write a plain-language scorecard to the GitHub job summary (true or false)."
required: false
default: "true"
ref:
description: "Deprecated compatibility input. The scorer is bundled with the Action release, so its version always matches the Action ref."
required: false
default: ""
runs:
using: "composite"
steps:
- name: Set up Java for the GTFS validator
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: temurin
java-version: "17"
- name: Set up uv
uses: astral-sh/setup-uv@eb1897b8dc4b5d5bfe39a428a8f2304605e0983c # v7.0.0
with:
version: "0.11.29"
enable-cache: false
ignore-empty-workdir: true
- name: Run the scorecard gate
id: gate
shell: bash
env:
FEED_URL: ${{ inputs.feed-url }}
MIN_GRADE: ${{ inputs.min-grade }}
MIN_DAYS: ${{ inputs.min-days-to-expiry }}
FEED_NAME: ${{ inputs.name }}
FEED_COUNTRY: ${{ inputs.country }}
HTML_OUT: ${{ inputs.html }}
JSON_OUT: ${{ inputs.json }}
WRITE_SUMMARY: ${{ inputs.summary }}
# Keep the downloaded Action tree immutable and all feed/validator
# scratch data under the runner's temporary directory.
SCORECARD_ROOT: ${{ runner.temp }}/gtfs-scorecard-work
UV_PROJECT_ENVIRONMENT: ${{ runner.temp }}/gtfs-scorecard-venv
run: |
set -euo pipefail
result_json="${JSON_OUT:-${RUNNER_TEMP}/gtfs-scorecard-result.json}"
args=("$FEED_URL")
args+=(--country "$FEED_COUNTRY")
if [[ -n "$FEED_NAME" ]]; then args+=(--name "$FEED_NAME"); fi
if [[ -n "$HTML_OUT" ]]; then args+=(--html "$HTML_OUT"); fi
if [[ -n "$MIN_GRADE" ]]; then args+=(--min-grade "$MIN_GRADE"); fi
if [[ -n "$MIN_DAYS" ]]; then args+=(--min-days-to-expiry "$MIN_DAYS"); fi
args+=(--json-out "$result_json")
set +e
uv run --project "${GITHUB_ACTION_PATH}/pipeline" --locked --no-dev \
scorecard try "${args[@]}"
gate_rc=$?
set -e
python "${GITHUB_ACTION_PATH}/action/render_result.py" \
--json "$result_json" \
--gate-rc "$gate_rc" \
--min-grade "$MIN_GRADE" \
--min-days "$MIN_DAYS" \
--write-summary "$WRITE_SUMMARY"
exit "$gate_rc"