-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathjustfile
More file actions
186 lines (168 loc) · 5.95 KB
/
Copy pathjustfile
File metadata and controls
186 lines (168 loc) · 5.95 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
set quiet # Recipes are silent by default
set export # Just variables are exported to the environment
mod security
[private]
default:
just --list
# Lint everything
[group("dev")]
lint:
# Lint the GitHub workflows
uvx --from=actionlint-py actionlint
# List all repositories owned by the Observability teams, deduped and sorted
[group("info")]
list-repos:
#!/usr/bin/env bash
set -euo pipefail
# GitHub team slugs under the 'canonical' org (bare slugs, no 'canonical/' prefix)
teams=(observability tracing-and-profiling observability-core)
# Repos to exclude, as full names (e.g. canonical/observability)
ignore=(canonical/observability)
{
for team in "${teams[@]}"; do
gh api "orgs/canonical/teams/${team}/repos" --paginate \
| jq -r '.[] | select(.archived == false and .disabled == false) | .full_name'
done
} | { grep -vxF -f <(printf '%s\n' "${ignore[@]}") || true; } | sort -u
# List all charms from the manifest
[group("info")]
list-charms:
#!/usr/bin/env bash
set -euo pipefail
yq -r '.artifacts.charms[].name' manifest.yaml | sort -u
# List all repositories of charms from the manifest
[group("info")]
list-charm-repos:
#!/usr/bin/env bash
set -euo pipefail
yq -r '.artifacts.charms[].repo' manifest.yaml | sort -u
# List all rocks from the manifest
[group("info")]
list-rocks:
#!/usr/bin/env bash
set -euo pipefail
yq -r '.artifacts.rocks[].name' manifest.yaml | sort -u
# List all repositories of rocks from the manifest
[group("info")]
list-rock-repos:
#!/usr/bin/env bash
set -euo pipefail
yq -r '.artifacts.rocks[].repo' manifest.yaml | sort -u
# List all snaps from the manifest
[group("info")]
list-snaps:
#!/usr/bin/env bash
set -euo pipefail
yq -r '.artifacts.snaps[].name' manifest.yaml | sort -u
# List all repositories of snaps from the manifest
[group("info")]
list-snap-repos:
#!/usr/bin/env bash
set -euo pipefail
yq -r '.artifacts.snaps[].repo' manifest.yaml | sort -u
# List all releases from the manifest that are past their end of life
[group("manifest")]
list-expired:
#!/usr/bin/env bash
set -euo pipefail
today=$(date +%F)
yq -o=json manifest.yaml | jq -r --arg today "$today" '
.artifacts
| to_entries[]
| .key as $type
| .value[]
| .name as $artifact
| .releases[]?
| select(.support.end_of_life != null and .support.end_of_life < $today)
| [$type, $artifact, .name, .support.end_of_life] | @tsv
' | column -t -s $'\t'
# Remove releases from the manifest that are past their end of life
[group("manifest")]
remove-expired:
#!/usr/bin/env bash
set -euo pipefail
echo "Removing the following EOL releases:"
just list-expired
export TODAY=$(date +%F)
yq -i '
(.. | select(has("releases")) | .releases)
|= map(select(.support.end_of_life == null or .support.end_of_life >= strenv(TODAY)))
' manifest.yaml
# Set a secret for all unarchived repositories of one or more GitHub teams
[group("secrets")]
set-team-secret secret +teams:
#!/usr/bin/env bash
set -euo pipefail
if [[ -z "${{secret}}" ]]; then
echo "You must set the {{secret}} environment variable with the secret contents."
exit 1
fi
for team in {{teams}}; do
gh api "orgs/canonical/teams/${team}/repos" --paginate \
| jq -r '.[] | select(.archived == false and .disabled == false) | .full_name'
done | sort -u | while read -r repo; do
gh secret set "{{secret}}" --repo "$repo" --body "${{secret}}"
done
# Set a secret for all charm repositories from the manifest
[group("secrets")]
set-charm-secret secret:
#!/usr/bin/env bash
set -euo pipefail
if [[ -z "${{secret}}" ]]; then
echo "You must set the {{secret}} environment variable with the secret contents."
exit 1
fi
just list-charm-repos | while read -r repo; do
gh secret set "{{secret}}" --repo "$repo" --body "${{secret}}"
done
# Set a secret for all snap repositories from the manifest
[group("secrets")]
set-snap-secret secret:
#!/usr/bin/env bash
set -euo pipefail
if [[ -z "${{secret}}" ]]; then
echo "You must set the {{secret}} environment variable with the secret contents."
exit 1
fi
just list-snap-repos | while read -r repo; do
gh secret set "{{secret}}" --repo "$repo" --body "${{secret}}"
done
# Set a secret for all rock repositories from the manifest
[group("secrets")]
set-rock-secret secret:
#!/usr/bin/env bash
set -euo pipefail
if [[ -z "${{secret}}" ]]; then
echo "You must set the {{secret}} environment variable with the secret contents."
exit 1
fi
just list-rock-repos | while read -r repo; do
gh secret set "{{secret}}" --repo "$repo" --body "${{secret}}"
done
# Promote a charm through all non-dev/non-latest tracks (beta→candidate, edge→beta)
[group("maintenance")]
promote-charm-train charm:
#!/usr/bin/env bash
set -euo pipefail
tracks=$(juju info {{charm}} --format=json | jq -r '.tracks[]')
for track in $tracks; do
if [[ "$track" == "dev" || "$track" == "latest" ]]; then
continue
fi
echo "Promoting {{charm}} on track ${track}..."
# FIXME: We're shortcircuiting this until we have quality gates in place, so that `/edge` goes directly to `/candidate`
# charmcraft promote --yes --name "{{charm}}" --from-channel="${track}/beta" --to-channel="${track}/candidate"
# charmcraft promote --yes --name "{{charm}}" --from-channel="${track}/edge" --to-channel="${track}/beta"
charmcraft promote --yes --name "{{charm}}" --from-channel="${track}/edge" --to-channel="${track}/beta"
charmcraft promote --yes --name "{{charm}}" --from-channel="${track}/edge" --to-channel="${track}/candidate"
done
# Promote a snap through all available tracks (edge→stable)
[group("maintenance")]
promote-snap-train snap:
#!/usr/bin/env bash
set -euo pipefail
tracks=$(snapcraft tracks {{snap}} | tail -n +2 | awk '{print $1}')
for track in $tracks; do
echo "Promoting {{snap}} on track ${track}..."
snapcraft promote --yes {{snap}} --from-channel="${track}/edge" --to-channel="${track}/stable"
done