-
Notifications
You must be signed in to change notification settings - Fork 2
89 lines (79 loc) · 3.95 KB
/
sanity-checks.yml
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
name: Sanity Checks
on:
pull_request:
permissions:
contents: read
jobs:
verify:
name: Check whether devcontainer files are updated
runs-on: ubuntu-latest
steps:
- name: Check out the source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Check changed files (images)
run: |
base="${{ github.event.pull_request.base.sha }}"
head="${{ github.event.pull_request.head.sha }}"
for image in images/src/*; do
changes="$(git diff --merge-base --name-only "${base}" "${head}" -- "${image}" | grep -Fv "${image}/README.md" || true)"
if [ -n "${changes}" ]; then
if ! echo "${changes}" | grep -q "${image}/.devcontainer.json"; then
echo "::error::Changes were made to ${image}, but the corresponding .devcontainer.json was not updated"
echo FAIL=1 >> "${GITHUB_ENV}"
else
base_version="$(git show "${base}:${image}/.devcontainer.json" | jq -r '.["x-build"]["image-version"]')"
head_version="$(git show "${head}:${image}/.devcontainer.json" | jq -r '.["x-build"]["image-version"]')"
if [ "$base_version" = "$head_version" ]; then
echo "::error::The image-version in ${image}/.devcontainer.json was not updated"
echo FAIL=1 >> "${GITHUB_ENV}"
fi
fi
fi
done
- name: Check changed files (features)
run: |
base="${{ github.event.pull_request.base.sha }}"
head="${{ github.event.pull_request.head.sha }}"
for feature in features/src/*; do
changes="$(git diff --merge-base --name-only "${base}" "${head}" -- "${feature}" | grep -Ev "${feature}/(README|NOTES).md" || true)"
if [ -n "${changes}" ]; then
if ! echo "${changes}" | grep -q "${feature}/devcontainer-feature.json"; then
echo "::error::Changes were made to ${feature}, but the corresponding devcontainer-feature.json was not updated"
echo FAIL=1 >> "${GITHUB_ENV}"
else
base_version="$(git show "${base}:${feature}/devcontainer-feature.json" | jq -r '.version')"
head_version="$(git show "${head}:${feature}/devcontainer-feature.json" | jq -r '.version')"
if [ "$base_version" = "$head_version" ]; then
echo "::error::The version in ${image}/devcontainer-feature.json was not updated"
echo FAIL=1 >> "${GITHUB_ENV}"
fi
fi
fi
done
- name: Check changed files (templates)
run: |
base="${{ github.event.pull_request.base.sha }}"
head="${{ github.event.pull_request.head.sha }}"
for template in templates/src/*; do
changes="$(git diff --merge-base --name-only "${base}" "${head}" -- "${template}" | grep -Fv "${template}/README.md" || true)"
if [ -n "${changes}" ]; then
if ! echo "${changes}" | grep -q "${template}/devcontainer-template.json"; then
echo "::error::Changes were made to ${template}, but the corresponding devcontainer-template.json was not updated"
echo FAIL=1 >> "${GITHUB_ENV}"
else
base_version="$(git show "${base}:${template}/devcontainer-template.json" | jq -r '.version')"
head_version="$(git show "${head}:${template}/devcontainer-template.json" | jq -r '.version')"
if [ "$base_version" = "$head_version" ]; then
echo "::error::The version in ${image}/devcontainer-template.json was not updated"
echo FAIL=1 >> "${GITHUB_ENV}"
fi
fi
fi
done
- name: Set check status
run: |
if [ "${{ env.FAIL }}" = "1" ]; then
exit 1
fi