-
Notifications
You must be signed in to change notification settings - Fork 17
186 lines (162 loc) · 6.62 KB
/
ci.yaml
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
name: CI
on:
pull_request: {}
push:
branches:
- master
jobs:
build:
name: Build
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-latest'
# - 'macos-latest'
ocaml-version:
# - 4.10.1
# - 4.11.1
- 4.12.0
snapshot:
- develop
- stable-0-0-10
- stable-0-0-8
- stable-0-0-7
- stable-0-0-6--1
- stable-0-0-6
- stable-0-0-5
include:
- os: 'ubuntu-latest'
ocaml-version: '4.07.1'
snapshot: stable-0-0-4
runs-on: ${{ matrix.os }}
env:
OPAMSOLVERTIMEOUT: 3600
OPAMVERBOSE: 1
SNAPSHOT: "snapshot-${{ matrix.snapshot }}"
steps:
- name: Checkout code (10 commits)
uses: actions/checkout@v2
with:
fetch-depth: 10
submodules: true
- name: Fetch master branch (50 commits)
run: |
git remote set-branches --add origin master
git fetch --depth 50 origin master
- name: Output Run ID/Number
run: echo ${{ github.run_id }} ${{ github.run_number }}
- name: Determine the default OPAM Repo
id: determine-default-opam-repo
# See https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#runner-context
# and https://github.com/ocaml/setup-ocaml/blob/4ac56b0fd440c3eef30fd1e34c96e0c740a807da/src/constants.ts#L45
run: |
if [ "${{ runner.os }}" = "Windows" ] ; then
DEFAULT_OPAM_REPO="https://github.com/fdopen/opam-repository-mingw.git#opam2"
else
DEFAULT_OPAM_REPO="https://github.com/ocaml/opam-repository.git"
fi
echo "::set-output name=opam-repo-default::$(echo "$DEFAULT_OPAM_REPO")"
- name: Setup OCaml ${{ matrix.ocaml-version }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-version }}
dune-cache: true
cache-prefix: "snapshot-${{ matrix.snapshot }}"
opam-depext: false
opam-pin: false
opam-repositories: |
satysfi-external: https://github.com/gfngfn/satysfi-external-repo.git
satyrographos-local: git+file://${{ github.workspace }}
default: ${{ steps.determine-default-opam-repo.outputs.opam-repo-default }}
- name: Create a dir for post-CI actions
run: |
set -exo pipefail
mkdir pr
- name: Check validity of the snapshot OPAM files
run: |
set -exo pipefail
opam lint --strict *.opam
- name: Check validity of the package OPAM files
run: |
set -exo pipefail
echo "### OPAM Lint" | tee -a "pr/comment.txt"
git diff --name-status origin/master... -- packages/ | sed -e '/^D/d' -e 's/^\w*\s//' -e '/\/opam/!d' | xargs opam lint --color=never --strict | tee -a "pr/comment.txt"
- name: Install the snapshot
run: |
opam pin add "${SNAPSHOT}.dev" . --no-action
opam depext "$SNAPSHOT" --yes
opam install "$SNAPSHOT" --yes
- name: Check if snapshot is consistent
run: |
set -exo pipefail
export OPAMCOLOR=never
comm --nocheck-order -13 <(opam list 'satysfi-*' --short --required-by "$SNAPSHOT") <(opam list 'satysfi-*' --short --recursive --required-by "$SNAPSHOT") > snapshot-diffs.txt
echo "### Missing libraries in the snapshot" | tee -a "pr/comment.txt"
cat snapshot-diffs.txt | tee -a "pr/comment.txt"
# echo "Requiring libraries:"
# cat snapshot-diffs.txt | xargs -r -L1 opam list 'satysfi-*' --recursive --required-by "$SNAPSHOT" --depends-on
- name: Detect file collisions in installed SATySFI libraries
run: |
opam exec -- satyrographos install test-satysfi-root
- name: Removing the snapshot
run: |
opam uninstall "$SNAPSHOT"
- name: Build against snapshots and oldest deps
run: |
export COMMENT_FILE=pr/comment.txt
export SKIP_REVERSE_DEPS=1
echo "### Snapshots and oldest deps" >>"$COMMENT_FILE"
./ci.sh
- name: Revdep tests
run: |
export COMMENT_FILE=pr/comment.txt
export SKIP_OLDEST_DEPS=1
echo "### Reverse deps" >>"$COMMENT_FILE"
./ci.sh
- name: Test if the packages can be added to the snapshot
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
# continue-on-error: true
id: test-update-snapshot
run: |
set -exo pipefail
echo "$SNAPSHOT" > pr/id.txt
echo "${{ matrix.snapshot }}; OCaml ${{ matrix.ocaml-version }}; ${{ matrix.os }}" > pr/matrix.txt
echo "${{ github.event.pull_request.number }}" > pr/pull-number.txt
echo "${{ github.run_id }}" > pr/run-id.txt
git checkout "$SNAPSHOT.opam"
scripts/update-snapshot --opam "$SNAPSHOT.opam"
git diff HEAD -- "$SNAPSHOT.opam" | sed -ne '/^+ /{ s!^+ *"\([^"]*\)".*"\([^"]*\)".*$!\1.\2! ; p}' | tr '\n' ' ' > pr/packages.txt
if git diff --quiet HEAD -- "$SNAPSHOT.opam" ; then
echo 'no-updates' > pr/result.txt
exit 0
fi
FAILED=
git add "$SNAPSHOT.opam"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m 'Update snapshot'
opam update
if ! opam install "$SNAPSHOT" --yes --with-doc --with-test --verbose --dry-run ; then
echo 'failed' > pr/result.txt
elif ! opam install "$SNAPSHOT" --yes --with-doc --with-test --verbose ; then
echo 'failed' > pr/result.txt
FAILED=1
else
opam list --color=never 'satysfi-*' --short --required-by "$SNAPSHOT" > snapshot-deps.txt
opam list --color=never 'satysfi-*' --short --recursive --required-by "$SNAPSHOT" > snapshot-recursive-deps.txt
if ! diff -u snapshot-deps.txt snapshot-recursive-deps.txt | sed -e '1,/^@@/d' | awk 'BEGIN{ORS=" "; print "inconsistent-snapshot"}; /^[-+]/ {print}' > pr/result.txt ; then
:
else
echo 'updated' > pr/result.txt
fi
fi
opam uninstall "$SNAPSHOT" --yes
if [ -n "$FAILED" ] ; then
exit 1
fi
- uses: actions/upload-artifact@v2
if: success() || failure()
with:
name: "pr-snapshot-${{ matrix.snapshot }}-${{ matrix.ocaml-version }}-${{ matrix.os }}"
path: pr/