From 394f28fa2fbec2f01f20246655c47dee0094740a Mon Sep 17 00:00:00 2001 From: Romain Beauxis Date: Sun, 14 Jan 2024 13:00:57 -0600 Subject: [PATCH] Convert tests to native github CI. --- .github/workflows/ci.yml | 36 ++++++++++- .../menhirLib-windows.20231231/opam | 29 +++++++++ tests/run_tests.sh | 63 +++++++++++-------- 3 files changed, 101 insertions(+), 27 deletions(-) create mode 100644 packages/menhirLib-windows/menhirLib-windows.20231231/opam diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5cbd63af..95cabcf2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,14 +14,46 @@ jobs: with: access_token: ${{ github.token }} + build_details: + runs-on: ubuntu-latest + outputs: + packages: ${{ steps.packages.outputs.packages }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Grab packages to build + id: packages + run: | + PACKAGES_TO_RUN=$(OUTPUT_ONLY=true ./tests/run_tests.sh | while read i; do echo "\\\"$i\\\""; done | xargs | sed -e 's# #,#g' | tr -d '\n') + echo "Packages to run: ${PACKAGES_TO_RUN}" + echo "packages=[${PACKAGES_TO_RUN}]" >> "${GITHUB_OUTPUT}" + test: runs-on: ubuntu-latest + needs: build_details strategy: fail-fast: false matrix: + package: ${{ fromJson(needs.build_details.outputs.packages) }} arch: [x64, x86] + ocaml_version: [4.14.1] + container: + image: ocamlcross/windows-${{ matrix.arch }}-base:${{ matrix.ocaml_version }} + options: --user root steps: - name: Checkout code uses: actions/checkout@v2 - - name: Run tests - run: VERBOSE=1 SYSTEM_TYPE=${{ matrix.arch }} ./tests/run_tests.sh + - name: Build package + env: + PKG_CONFIG_PATH: ${{ matrix.arch == 'x64' && '/usr/src/mxe/usr/x86_64-w64-mingw32.static/lib/pkgconfig/' || '/usr/src/mxe/usr/i686-w64-mingw32.static/lib/pkgconfig/' }} + run: | + rm -rf /home/opam/opam-cross-windows/packages /home/opam/opam-cross-windows/repo + mv packages /home/opam/opam-cross-windows + mv repo /home/opam/opam-cross-windows + sudo -u opam opam update + sudo -u opam opam list --short --recursive --external --vars os-distribution=mxe,os-family=mingw --required-by=${{ matrix.package }} > /home/opam/mxe-deps + if [ -s /home/opam/mxe-deps ]; then + cd /usr/src/mxe/ && cat /home/opam/mxe-deps | xargs make + fi + eval $(sudo -u opam opam env) + sudo -u opam opam reinstall --verbose -y ${{ matrix.package }} diff --git a/packages/menhirLib-windows/menhirLib-windows.20231231/opam b/packages/menhirLib-windows/menhirLib-windows.20231231/opam new file mode 100644 index 00000000..03e218ad --- /dev/null +++ b/packages/menhirLib-windows/menhirLib-windows.20231231/opam @@ -0,0 +1,29 @@ +opam-version: "2.0" +maintainer: "francois.pottier@inria.fr" +authors: [ + "François Pottier " + "Yann Régis-Gianas " +] +homepage: "http://gitlab.inria.fr/fpottier/menhir" +dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" +bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" +license: "LGPL-2.0-only with OCaml-LGPL-linking-exception" +build: [ + ["dune" "build" "-x" "windows" "-p" "menhirLib" "-j" jobs] +] +depends: [ + "ocaml" { >= "4.03.0" } + "dune" { >= "2.8.0" } +] +conflicts: [ + "menhir" { != version } +] +synopsis: "Runtime support library for parsers generated by Menhir" +url { + src: + "https://gitlab.inria.fr/fpottier/menhir/-/archive/20231231/archive.tar.gz" + checksum: [ + "md5=799748bc3b7a542798a85956c7863865" + "sha512=620ff3443143535e03ac98c5e8ee2ddf9ba48f8cfe441302118def1da3e03ffac7f48d4d4cb129766b625ecad0fb341da1baa0169dee8b6d07a5b0bbb735cf2f" + ] +} diff --git a/tests/run_tests.sh b/tests/run_tests.sh index d6333569..8363471b 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -1,5 +1,7 @@ #!/bin/sh +# Set OUTPUT_ONLY env variable to only output packages to rebuild. + TEST_PWD=$(cd `dirname $0` && pwd) BASE_PWD=$(cd ${TEST_PWD}/.. && pwd) @@ -51,21 +53,23 @@ SKIPPED="${SKIPPED} lwt-zmq-windows.2.1.0 zmq-windows.4.0-7" PRETEST_IMAGE="ocamlcross/windows-${SYSTEM_TYPE}-pretest:${OCAML_VERSION}" -printf "Building ${PRETEST_IMAGE}.." -DOCKER_CMD="docker build --no-cache -f ${TEST_PWD}/Dockerfile.pretest \ - --build-arg \"IMAGE=${BASE_IMAGE}\" -t \"${PRETEST_IMAGE}\" ${BASE_PWD}" +if [ -z "${OUTPUT_ONLY}" ]; then + printf "Building ${PRETEST_IMAGE}.." + DOCKER_CMD="docker build --no-cache -f ${TEST_PWD}/Dockerfile.pretest \ + --build-arg \"IMAGE=${BASE_IMAGE}\" -t \"${PRETEST_IMAGE}\" ${BASE_PWD}" -if [ -n "${VERBOSE}" ]; then - echo "" - /bin/sh -c "${DOCKER_CMD}" -else - /bin/sh -c "${DOCKER_CMD} >/dev/null" -fi + if [ -n "${VERBOSE}" ]; then + echo "" + /bin/sh -c "${DOCKER_CMD}" + else + /bin/sh -c "${DOCKER_CMD} >/dev/null" + fi -if [ "$?" -ne "0" ]; then - printf "\033[0;31m[failed]\033[0m🚫🚫 \n" -else - printf "\033[0;32m[ok]\033[0m✅ \n" + if [ "$?" -ne "0" ]; then + printf "\033[0;31m[failed]\033[0m🚫🚫 \n" + else + printf "\033[0;32m[ok]\033[0m✅ \n" + fi fi build_package() { @@ -74,32 +78,41 @@ build_package() { echo "${SKIPPED}" | grep "${PACKAGE}" >/dev/null 2>&1 if [ "$?" -eq "0" ]; then - printf "Building ${PACKAGE}.. \033[1;33m[skipped]\033[0m⚠️\n" + if [ -n "${OUTPUT_ONLY}" ]; then + exit 0 + else + printf "Building ${PACKAGE}.. \033[1;33m[skipped]\033[0m⚠️\n" + fi else - SYSTEM_TYPE="${SYSTEM_TYPE}" OCAML_VERSION="${OCAML_VERSION}" ${TEST_PWD}/run_test.sh "${PACKAGE}" - - if [ "$?" -ne "0" ]; then - exit 128 + if [ -n "${OUTPUT_ONLY}" ]; then + echo "${PACKAGE}" + exit 0 + else + SYSTEM_TYPE="${SYSTEM_TYPE}" OCAML_VERSION="${OCAML_VERSION}" ${TEST_PWD}/run_test.sh "${PACKAGE}" + + if [ "$?" -ne "0" ]; then + exit 128 + fi fi fi } PACKAGES=$(cd ${BASE_PWD}/packages && find . -maxdepth 2 -mindepth 2 -type d | cut -d '/' -f 3 | sort -u) -echo "" -git remote set-branches origin '*' -git fetch origin main -echo "" +git remote set-branches origin '*' >/dev/null 2>&1 +git fetch origin main >/dev/null 2>&1 echo "${PACKAGES}" | while read PACKAGE; do if [ -n "${WORLD}" ]; then build_package "${PACKAGE}" else PACKAGE_DIR=`echo ${PACKAGE} | cut -d'.' -f 1` - RET=$(cd "${BASE_PWD}/packages/${PACKAGE_DIR}/${PACKAGE}" && git diff --name-only HEAD origin/main .) + if [ -d "${BASE_PWD}/packages/${PACKAGE_DIR}/${PACKAGE}" ]; then + RET=$(cd "${BASE_PWD}/packages/${PACKAGE_DIR}/${PACKAGE}" && git diff --name-only HEAD origin/main .) - if [ -n "${RET}" ]; then - build_package "${PACKAGE}" + if [ -n "${RET}" ]; then + build_package "${PACKAGE}" + fi fi fi done