Skip to content

Commit

Permalink
factor debian CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
andres-erbsen committed Aug 11, 2023
1 parent c65632e commit 8d12f39
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 48 deletions.
65 changes: 17 additions & 48 deletions .github/workflows/coq-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,22 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: bootstrap
run: |
sudo mkdir /chroot
sudo apt-get -q -y -o Acquire::Retries=30 update
sudo apt-get -q -y -o Acquire::Retries=30 install debootstrap
sudo debootstrap --variant=minbase "$DEBIAN" /chroot http://debian-archive.trafficmanager.net/debian/ || ( cat /tmp/tmp.*/debootstrap/debootstrap.log ; exit 1 )
sudo mount proc /chroot/proc -t proc
sudo mount sysfs /chroot/sys -t sysfs
sudo chroot /chroot apt-get -q -y -o Acquire::Retries=30 install ca-certificates git make time jq python3 python-is-python3 ocaml coq libcoq-core-ocaml-dev libfindlib-ocaml-dev ocaml-findlib cabal-install
sudo chroot /chroot groupadd -g "$(id -g)" "$(id -g -n)"
sudo chroot /chroot useradd -g "$(id -g)" -u "$(id -u)" "$(id -u -n)"
sudo mkdir -p "/chroot/$(pwd)"
sudo chown "$(id -u):$(id -g)" "/chroot/$(pwd)"
sudo mount --bind "$(pwd)" "/chroot/$(pwd)"
- name: setup Debian chroot
run: etc/ci/setup-debian-chroot.sh "$DEBIAN"
- name: host build params
run: |
"$(pwd)/etc/ci/describe-system-config.sh"
run: etc/ci/describe-system-config.sh
- name: chroot build params
run: |
sudo chroot /chroot setpriv --reuid "$(id -u)" --regid "$(id -g)" --init-groups \
"$(pwd)/etc/ci/describe-system-config.sh"
shell: in-debian-chroot.sh {0}
run: etc/ci/describe-system-config.sh
- name: make deps
run: |
sudo chroot /chroot setpriv --reuid "$(id -u)" --regid "$(id -g)" --init-groups \
"$(pwd)/etc/ci/github-actions-make.sh" -C "$(pwd)" -j2 deps
shell: in-debian-chroot.sh {0}
run: etc/ci/github-actions-make.sh -j2 deps
- name: all-except-generated
run: |
sudo chroot /chroot setpriv --reuid "$(id -u)" --regid "$(id -g)" --init-groups \
"$(pwd)/etc/ci/github-actions-make.sh" -C "$(pwd)" -j2 all-except-generated
shell: in-debian-chroot.sh {0}
run: etc/ci/github-actions-make.sh -j2 all-except-generated
- name: generated-files
run: |
sudo chroot /chroot setpriv --reuid "$(id -u)" --regid "$(id -g)" --init-groups \
"$(pwd)/etc/ci/github-actions-make.sh" -C "$(pwd)" -j2 generated-files
shell: in-debian-chroot.sh {0}
run: etc/ci/github-actions-make.sh -j2 generated-files
- run: tar -czvf generated-files.tgz fiat-*/
if: ${{ failure() }}
- name: upload generated files
Expand All @@ -78,9 +61,8 @@ jobs:
path: src/ExtractionOCaml
if: always ()
- name: standalone-haskell
run: |
sudo chroot /chroot setpriv --reuid "$(id -u)" --regid "$(id -g)" --init-groups \
"$(pwd)/etc/ci/github-actions-make.sh" -C "$(pwd)" -j1 standalone-haskell GHCFLAGS='+RTS -M6G -RTS'
shell: in-debian-chroot.sh {0}
run: etc/ci/github-actions-make.sh -j1 standalone-haskell GHCFLAGS='+RTS -M6G -RTS'
- name: upload Haskell files
uses: actions/upload-artifact@v3
with:
Expand All @@ -107,20 +89,8 @@ jobs:
uses: actions/checkout@v3
with:
submodules: recursive
- name: bootstrap
run: |
sudo mkdir /chroot
sudo apt-get -q -y -o Acquire::Retries=30 update
sudo apt-get -q -y -o Acquire::Retries=30 install debootstrap
sudo debootstrap --variant=minbase "$DEBIAN" /chroot http://debian-archive.trafficmanager.net/debian/ || ( cat /tmp/tmp.*/debootstrap/debootstrap.log ; exit 1 )
sudo mount proc /chroot/proc -t proc
sudo mount sysfs /chroot/sys -t sysfs
sudo chroot /chroot apt-get -q -y -o Acquire::Retries=30 install ca-certificates git make time jq python3 python-is-python3 ocaml coq libcoq-core-ocaml-dev libfindlib-ocaml-dev ocaml-findlib cabal-install
sudo chroot /chroot groupadd -g "$(id -g)" "$(id -g -n)"
sudo chroot /chroot useradd -g "$(id -g)" -u "$(id -u)" "$(id -u -n)"
sudo mkdir -p "/chroot/$(pwd)"
sudo chown "$(id -u):$(id -g)" "/chroot/$(pwd)"
sudo mount --bind "$(pwd)" "/chroot/$(pwd)"
- name: setup Debian chroot
run: etc/ci/setup-debian-chroot.sh "$DEBIAN"
- name: Download a Build Artifact
uses: actions/download-artifact@v3
with:
Expand All @@ -129,8 +99,7 @@ jobs:
- name: make binaries executable
run: git check-ignore src/ExtractionOCaml/* | grep -v '\.' | xargs chmod +x
- name: make only-test-amd64-files
run: |
sudo chroot /chroot setpriv --reuid "$(id -u)" --regid "$(id -g)" --init-groups \
"$(pwd)/etc/ci/github-actions-make.sh" -C "$(pwd)" -j2 only-test-amd64-files SLOWEST_FIRST=1
shell: in-debian-chroot.sh {0}
run: etc/ci/github-actions-make.sh -j2 only-test-amd64-files SLOWEST_FIRST=1
env:
ALLOW_DIFF: 1
1 change: 1 addition & 0 deletions etc/ci/describe-system-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ group coqc --config
group coqc --version
group "true | coqtop"
group etc/machine.sh
group "echo PATH=$PATH"
7 changes: 7 additions & 0 deletions etc/ci/in-debian-chroot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -e -u -x

# This script is intended to be called from github hosted runners only.

exec sudo chroot /chroot setpriv --reuid "$(id -u)" --regid "$(id -g)" --init-groups \
/bin/sh -e -u -x -c 'cd "$1"; shift; exec sh -e -u -x "$@"' -- "$(pwd)" "$@"
22 changes: 22 additions & 0 deletions etc/ci/setup-debian-chroot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#/bin/sh
set -e -u -x
debian="$1"

# This script is intended to be called from github hosted runners only.
# It does not clean up after itself.

sudo mkdir /chroot
sudo apt-get -q -y -o Acquire::Retries=30 update
sudo apt-get -q -y -o Acquire::Retries=30 install debootstrap
sudo debootstrap --variant=minbase "$debian" /chroot http://debian-archive.trafficmanager.net/debian/ || ( cat /tmp/tmp.*/debootstrap/debootstrap.log ; exit 1 )
sudo mount proc /chroot/proc -t proc
sudo mount sysfs /chroot/sys -t sysfs
sudo chroot /chroot apt-get -q -y -o Acquire::Retries=30 install sudo git make time jq python3 python-is-python3 ocaml coq libcoq-core-ocaml-dev libfindlib-ocaml-dev ocaml-findlib cabal-install
sudo chroot /chroot groupadd -g "$(id -g)" "$(id -g -n)"
sudo chroot /chroot useradd -g "$(id -g)" -u "$(id -u)" "$(id -u -n)"
printf "%s ALL=(ALL) NOPASSWD: ALL\n" "$(id -u -n)" | sudo tee /chroot/etc/sudoers.d/root
sudo mkdir -p "/chroot/$HOME"
sudo chown "$(id -u):$(id -g)" "/chroot/$HOME"
sudo mount --bind "$HOME" "/chroot/$HOME"

( cd "$(dirname "$0")" && pwd ) | tee -a "$GITHUB_PATH"

0 comments on commit 8d12f39

Please sign in to comment.