-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
159 lines (135 loc) · 4.99 KB
/
Copy pathTaskfile.yml
File metadata and controls
159 lines (135 loc) · 4.99 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
---
version: "3"
vars:
PYTHON: '{{default "python3" .PYTHON}}'
FORCE_BRIEFING: '{{default "auto" .FORCE_BRIEFING}}'
STATE_RELEASE: '{{default "news-state" .STATE_RELEASE}}'
STATE_ASSET: '{{default "wazzup-state.zip" .STATE_ASSET}}'
TRANSPARENCY_REPORT_ASSET: '{{default "wazzup-transparency-report.md" .TRANSPARENCY_REPORT_ASSET}}'
env:
PYTHONPATH: src
tasks:
default:
desc: Run the standard CI task set
cmds:
- task: ci
install:
desc: Install Python dependencies
cmds:
- '{{.PYTHON}} -m pip install -r requirements.txt'
hooks:install:
desc: Install lefthook git hooks
cmds:
- lefthook install
hooks:run:
desc: Run lefthook pre-commit hooks manually
cmds:
- lefthook run pre-commit
format:check:
desc: Check lightweight formatting rules
cmds:
- '{{.PYTHON}} scripts/check_format.py'
lint:
desc: Run lightweight Python syntax linting
cmds:
- '{{.PYTHON}} scripts/lint.py'
test:
desc: Run unit and integration tests
cmds:
- '{{.PYTHON}} -m unittest discover -s tests'
build:
desc: Compile Python modules
cmds:
- '{{.PYTHON}} -m compileall -q src scripts'
build:metadata:
desc: Write static build metadata for the PWA footer and service worker version
cmds:
- '{{.PYTHON}} -m wazzup.build_info'
pipeline:generate:
desc: Generate static briefing data
cmds:
- task: build:metadata
- '{{.PYTHON}} -m wazzup.pipeline --force-briefing "{{.FORCE_BRIEFING}}"'
pipeline:generate:fixtures:
desc: Generate static briefing data from committed fixtures
env:
AI_PROVIDER: fake
cmds:
- task: build:metadata
- '{{.PYTHON}} -m wazzup.pipeline --fixture-dir tests/fixtures --force-briefing "{{.FORCE_BRIEFING}}"'
validate:data:
desc: Validate generated static data
cmds:
- '{{.PYTHON}} -m wazzup.validate_data public/data'
state:restore:
desc: Restore retained generated-data state from the GitHub Release asset
cmds:
- |-
set -euo pipefail
mkdir -p .state
repository="${GITHUB_REPOSITORY:-DevSecNinja/wazzup}"
server_url="${GITHUB_SERVER_URL:-https://github.com}"
asset_url="${server_url}/${repository}/releases/download/{{.STATE_RELEASE}}/{{.STATE_ASSET}}"
restored=false
if [[ -n "${GH_TOKEN:-}${GITHUB_TOKEN:-}" ]] && gh release download {{.STATE_RELEASE}} --pattern {{.STATE_ASSET}} --dir .state --repo "${repository}"; then
restored=true
elif curl -fsSL --retry 3 --retry-delay 2 "${asset_url}" -o .state/{{.STATE_ASSET}}; then
restored=true
fi
if [[ "${restored}" == "true" ]]; then
unzip -q -o .state/{{.STATE_ASSET}} -d public
echo "Restored retained news state from the {{.STATE_RELEASE}} release."
else
echo "::notice::No retained {{.STATE_RELEASE}} release asset found; starting from an empty data window."
if [[ "${STATE_REQUIRED:-false}" == "true" ]]; then
echo "::error::Pages builds require retained state. Run the News workflow first."
exit 1
fi
fi
state:persist:
desc: Persist retained generated-data state to the GitHub Release asset
cmds:
- |-
set -euo pipefail
mkdir -p .state
(cd public && zip -qr ../.state/{{.STATE_ASSET}} data)
if [[ -f public/data/transparency/latest.md ]]; then
cp public/data/transparency/latest.md .state/{{.TRANSPARENCY_REPORT_ASSET}}
fi
if gh release view {{.STATE_RELEASE}} --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
gh release upload {{.STATE_RELEASE}} .state/{{.STATE_ASSET}} --clobber --repo "${GITHUB_REPOSITORY}"
if [[ -f .state/{{.TRANSPARENCY_REPORT_ASSET}} ]]; then
gh release upload {{.STATE_RELEASE}} .state/{{.TRANSPARENCY_REPORT_ASSET}} --clobber --repo "${GITHUB_REPOSITORY}"
fi
else
gh release create {{.STATE_RELEASE}} .state/{{.STATE_ASSET}} \
--title "Wazzup retained news state" \
--notes "Rolling generated YAML state and JSON mirrors for the Wazzup GitHub Pages deployment." \
--prerelease \
--repo "${GITHUB_REPOSITORY}"
if [[ -f .state/{{.TRANSPARENCY_REPORT_ASSET}} ]]; then
gh release upload {{.STATE_RELEASE}} .state/{{.TRANSPARENCY_REPORT_ASSET}} --clobber --repo "${GITHUB_REPOSITORY}"
fi
fi
news:generate:
desc: Restore state, generate a briefing, validate data, and persist state
cmds:
- task: state:restore
- task: pipeline:generate
- task: validate:data
- task: state:persist
pages:build:
desc: Restore retained state and validate the Pages artifact
env:
STATE_REQUIRED: "true"
cmds:
- task: build:metadata
- task: state:restore
- task: validate:data
ci:
desc: Run all local validation checks
cmds:
- task: format:check
- task: lint
- task: test
- task: build