From ed237bd29e84000e7e09058a2d2be2a54ea60c7f Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sun, 12 Nov 2023 18:49:10 +0100 Subject: [PATCH] CI: Test GitHub Actions support --- .github/workflows/main.yml | 47 ++++++++++++++++++++++++++++++ buildci.sh | 58 +++++++++++++++++++++++++++++--------- 2 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000000..bab3594dedc3 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,47 @@ +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions + +name: Main +on: + - push # branch or tag + +jobs: + linux: + strategy: + fail-fast: false + matrix: + include: + - job_name: ubuntu-x86_64 (testsuite) + target: x86_64-linux-gnu + - job_name: ubuntu-x86_64 (unittests) + target: x86_64-linux-gnu + - job_name: ubuntu-arm + target: arm-linux-gnueabi + #- job_name: ubuntu-armhf + # target: arm-linux-gnueabihf + - job_name: ubuntu-aarch64 + target: aarch64-linux-gnu + - job_name: ubuntu-mips + target: mips-linux-gnu + - job_name: ubuntu-mips64el + target: mips64el-linux-gnuabi64 + - job_name: ubuntu-mipsel + target: mipsel-linux-gnu + name: ${{ matrix.job_name }} + runs-on: ubuntu-22.04 + env: + GCC_CI_TARGET: ${{ matrix.target }} + GCC_CI_BOOTSTRAP: ${{ matrix.bootstrap || false }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 10 + - name: Install dependencies + run: ./buildci.sh installdeps + - name: Configure gdc + run: ./buildci.sh configure + - name: Build gdc + run: ./buildci.sh build + - name: Run testsuite + run: ${{ contains(matrix.job_name, 'testsuite') && './buildci.sh testsuite' || 'echo disabled' }} + - name: Run unittests + run: ${{ contains(matrix.job_name, 'unittests') && './buildci.sh unittests' || 'echo disabled' }} diff --git a/buildci.sh b/buildci.sh index 482b766e237c..39c6836cc049 100755 --- a/buildci.sh +++ b/buildci.sh @@ -1,20 +1,16 @@ #!/bin/bash -# This script is intended to be ran on SemaphoreCI or Buildkite platform. -# Following environmental variables are assumed to be exported on SemaphoreCI. +# This script is intended to be ran on platform on GitHub Action +# Other CI platforms in this script are legacy and only kept around to keep +# the modularity of this script in check. # -# - SEMAPHORE_PROJECT_DIR -# - SEMAPHORE_CACHE_DIR +# Following environmental variables are assume to be exported on GitHub Actions. # -# See https://semaphoreci.com/docs/available-environment-variables.html +# - RUNNER_TOOL_CACHE +# - RUNNER_OS +# - GCC_CI_TARGET +# - GCC_CI_BOOTSTRAP # -# Following environmental variables are assumed to be exported on Buildkite. -# -# - BUILDKITE_CACHE_DIR -# - BUILDKITE_OS -# - BUILDKITE_TARGET -# - BUILDKITE_BOOTSTRAP -# -# See https://buildkite.com/docs/builds/environment-variables +# See https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables # ## Top-level build system configration. gcc_prereqs="gmp-6.1.0.tar.bz2 mpfr-3.1.6.tar.bz2 mpc-1.0.3.tar.gz isl-0.18.tar.bz2" @@ -127,6 +123,21 @@ environment() { build_target_canonical=${build_host_canonical} make_flags="-j$(nproc)" build_bootstrap="disable" + elif [ "${CI}" = "true" ]; then + export CC="gcc" + export CXX="g++" + export GDC="gdc" + gcc_prereqs="" + project_dir=${PWD} + cache_dir=${RUNNER_TOOL_CACHE} + log_dir=${PWD}/logs + mkdir -p ${log_dir} + make_flags="-j$(nproc)" + build_host=$($CC -dumpmachine) + build_host_canonical=$(${project_dir}/config.sub ${build_host}) + build_target=${GCC_CI_TARGET} + build_target_canonical=$(${project_dir}/config.sub ${build_target}) + build_bootstrap=${GCC_CI_BOOTSTRAP} else echo "Unhandled CI environment" exit 1 @@ -296,6 +307,27 @@ installdeps() { echo "Unhandled CI environment" exit 1 fi + elif [ "${CI}" = "true" ]; then + if [ "${RUNNER_OS}" = "Linux" ]; then + case ${GCC_CI_TARGET} in + arm*-*-*eabi) + install_packages="binutils-arm-linux-gnueabi libc6-dev-armel-cross" + ;; + aarch64-*-*) + install_packages="binutils-aarch64-linux-gnu libc6-dev-arm64-cross" + ;; + *) + install_packages="binutils libc6-dev" + ;; + esac + sudo apt-get update -qq + sudo apt-get install -qq gcc g++ gdc ${install_packages} \ + autogen autoconf automake dejagnu patch \ + libcurl4-gnutls-dev libgmp-dev libisl-dev libmpc-dev libmpfr-dev || exit 1 + else + echo "Unhandled CI environment" + exit 1 + fi else echo "Unhandled CI environment" exit 1