From 056c09d97e899c7d930f84fc03d4d4bfe89e4dd8 Mon Sep 17 00:00:00 2001 From: Andres Erbsen Date: Thu, 10 Aug 2023 22:08:03 +0000 Subject: [PATCH] factor debian CI scripts --- .github/workflows/coq-debian.yml | 65 +++++++++----------------------- etc/ci/in-debian-chroot.sh | 7 ++++ etc/ci/setup-debian-chroot.sh | 19 ++++++++++ 3 files changed, 43 insertions(+), 48 deletions(-) create mode 100755 etc/ci/in-debian-chroot.sh create mode 100755 etc/ci/setup-debian-chroot.sh diff --git a/.github/workflows/coq-debian.yml b/.github/workflows/coq-debian.yml index e7e186d088..ddf13dc6ca 100644 --- a/.github/workflows/coq-debian.yml +++ b/.github/workflows/coq-debian.yml @@ -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: etc/ci/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: etc/ci/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: etc/ci/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: etc/ci/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 @@ -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: etc/ci/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: @@ -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: @@ -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: etc/ci/in-debian-chroot.sh {0} + run: etc/ci/github-actions-make.sh -j2 only-test-amd64-files SLOWEST_FIRST=1 env: ALLOW_DIFF: 1 diff --git a/etc/ci/in-debian-chroot.sh b/etc/ci/in-debian-chroot.sh new file mode 100755 index 0000000000..a42e946222 --- /dev/null +++ b/etc/ci/in-debian-chroot.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -e -u + +# 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 -c 'cd "$1"; shift; exec "$@"' -- "$(pwd)" "$@" diff --git a/etc/ci/setup-debian-chroot.sh b/etc/ci/setup-debian-chroot.sh new file mode 100755 index 0000000000..c46e442ee7 --- /dev/null +++ b/etc/ci/setup-debian-chroot.sh @@ -0,0 +1,19 @@ +#/bin/sh +set -e -u +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 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)"