Debian Codegraph @

dev/tools/create_overlays.sh

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 #!/usr/bin/bashscip-shell filesystem . . `/usr/bin/bash`.
2
3 # TODO:
4 #
5 # - Check if the branch already exists in the remote => checkout
6 # - Better error handling
7 # - Just checkout, don't build
8 # - Rebase functionality
9 #
10
11 set -x
12 set -e
13 set -o pipefail
14
15 # setup_contrib_git("_build_ci/fiat", "https://github.com/ejgallego/fiat-core.git")
16 setup_contrib_gitscip-shell shell shell-project 0.0.0 setup_contrib_git().() {
17
18 local _DIR=$1
19 local _GITURL=$2
20
21 ( cd $_DIR
22 gitscip-shell system . . git. checkout -b $OVERLAY_BRANCH || truescip-shell system . . true. # allow the branch to exist already
23 gitscip-shell system . . git. remote add $DEVELOPER_NAME $_GITURL || truescip-shell system . . true. # allow the remote to exist already
24 if [scip-shell system . . `[`. -d .git ]; then # TODO handle submodules
25 template_file=.git/OVERLAY_COMMIT_TEMPLATE
26 printfscip-shell system . . printf. 'Adapt to rocq-prover/rocq#%s (short decription here)\n' "$PR_NUMBER" > "$template_file"
27
28 # don't override config if already set, maybe the user prefers something else
29 if ! gitscip-shell system . . git. config --get --local commit.template; then
30 gitscip-shell system . . git. config --local commit.template "$template_file"
31 fi
32 fi
33 )
34
35 }
36
37 if [scip-shell system . . `[`. $# -lt 3 ]; then
38 echoscip-shell system . . echo. "usage: $0 github_username pr_number contrib1 ... contribN"
39 exit 1
40 fi
41
42 set +x
43 . dev/ci/ci-basic-overlay.shscip-shell source . . `dev/ci/ci-basic-overlay.sh`.
44 set -x
45
46 DEVELOPER_NAME=$1
47 shift
48 PR_NUMBER=$1
49 shift
50 OVERLAY_BRANCH=$(gitscip-shell system . . git. rev-parse --abbrev-ref HEAD)
51 OVERLAY_FILE=$(mktempscip-shell system . . mktemp. overlay-XXXX)
52
53 # Create the overlay file
54 > "$OVERLAY_FILE"
55
56 skipped_repos=
57
58 # We first try to build the contribs
59 while testscip-shell system . . test. $# -gt 0
60 do
61 _CONTRIB_NAME=$1
62 _CONTRIB_GITURL=${_CONTRIB_NAME}_CI_GITURL
63 _CONTRIB_GITURL=${!_CONTRIB_GITURL}
64 _CONTRIB_SUBMODULE_GITURL=${_CONTRIB_NAME}_CI_SUBMODULE_GITURL
65 _CONTRIB_SUBMODULE_GITURL=${!_CONTRIB_SUBMODULE_GITURL}
66 _CONTRIB_SUBMODULE_BRANCH=${_CONTRIB_NAME}_CI_SUBMODULE_BRANCH
67 _CONTRIB_SUBMODULE_BRANCH=${!_CONTRIB_SUBMODULE_BRANCH}
68 if [[ -n "${_CONTRIB_SUBMODULE_GITURL}" ]]; then
69 _CONTRIB_GITURL="${_CONTRIB_SUBMODULE_GITURL}"
70 fi
71 echoscip-shell system . . echo. "Processing Contrib $_CONTRIB_NAME"
72 shift
73
74 # check _CONTRIB_GIT exists and it is of the from github...
75
76 _CONTRIB_DIR=_build_ci/$_CONTRIB_NAME
77
78 # extract the relevant part of the repository
79 if [[ $_CONTRIB_GITURL == https://github.com/*/* ]]; then
80 _CONTRIB_GITSUFFIX=${_CONTRIB_GITURL#https://github.com/*/}
81 _CONTRIB_GITURL="https://github.com/$DEVELOPER_NAME/$_CONTRIB_GITSUFFIX"
82 _CONTRIB_GITPUSHURL="[email protected]:$DEVELOPER_NAME/${_CONTRIB_GITSUFFIX}.git"
83 else
84 skipped_repos="$skipped_repos $_CONTRIB_NAME"
85 continue
86 fi
87
88 DOWNLOAD_ONLY=1 makescip-shell system . . make. ci-$_CONTRIB_NAME || truescip-shell system . . true.
89 setup_contrib_gitscip-shell shell shell-project 0.0.0 setup_contrib_git(). $_CONTRIB_DIR $_CONTRIB_GITPUSHURL
90
91 echoscip-shell system . . echo. "overlay ${_CONTRIB_NAME} $_CONTRIB_GITURL $OVERLAY_BRANCH $PR_NUMBER" >> $OVERLAY_FILE
92 if [scip-shell system . . `[`. -n "${_CONTRIB_SUBMODULE_BRANCH}${_CONTRIB_SUBMODULE_GITURL}" ]; then
93 echoscip-shell system . . echo. "# Make PRs against ${_CONTRIB_SUBMODULE_GITURL} base branch ${_CONTRIB_SUBMODULE_BRANCH}" >> $OVERLAY_FILE
94 fi
95 if [scip-shell system . . `[`. $# -gt 0 ]; then echoscip-shell system . . echo. "" >> $OVERLAY_FILE; fi
96 done
97
98 # Copy to overlays folder.
99 PR_NUMBER=$(printfscip-shell system . . printf. '%05d' "$PR_NUMBER")
100 mvscip-shell system . . mv. $OVERLAY_FILE dev/ci/user-overlays/$PR_NUMBER-$DEVELOPER_NAME-${OVERLAY_BRANCH///}.sh
101
102 if [scip-shell system . . `[`. -n "$skipped_repos" ]; then
103 >&2 echoscip-shell system . . echo. "Skipped non-github repos: $skipped_repos"
104 exit 1
105 fi