Skip to content

Commit

Permalink
Convert tests to native github CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Jan 14, 2024
1 parent 1542924 commit b8adee5
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 27 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,45 @@ 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: |
printf "["
OUTPUT_ONLY=true ./tests/run_tests.sh | while read i; do echo "\\\"$i\\\""; done | xargs | sed -e 's# #,#g'
printf "]"
test:
runs-on: ubuntu-latest
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
cd /usr/src/mxe/ && cat /home/opam/mxe-deps | xargs make
eval $(sudo -u opam opam env)
opam reinstall --verbose -y ${{ matrix.package }}
VERBOSE=1 SYSTEM_TYPE=${{ matrix.arch }} ./tests/run_tests.sh
29 changes: 29 additions & 0 deletions packages/menhirLib-windows/menhirLib-windows.20231231/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
opam-version: "2.0"
maintainer: "[email protected]"
authors: [
"François Pottier <[email protected]>"
"Yann Régis-Gianas <[email protected]>"
]
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"
]
}
63 changes: 38 additions & 25 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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() {
Expand All @@ -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
Expand Down

0 comments on commit b8adee5

Please sign in to comment.