From e4404071340ccf2f52319e602810e64448f81cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sat, 8 Nov 2025 18:12:36 +0000 Subject: [PATCH] Add basic CI via GitHub actions. Additionally: * Allow disabling setting up root password or sudo command wrangling (used in CI environment, but could be used by the end user via the MANAGE_SUDO environment variable). * gnustep-web-install and gnustep-web-install-dev also detect if they are run inside a working copy, assume this is CI environment, and skip cloning the repo itself. * Only gnustep-web-install (non-dev) is run in CI for now, as the dev version assumes ssh keys are set up to access private repos. This could be arranged in GitHub Actions, but is left for future improvement. No attempt was made to cache any part of the installation between runs, since we are trying to run the entire installation process as a test. It would be useful to have a smoke test that just verifies portions of the build, or to produce a custom container image that has at least the base dependencies installed. Then the full run could be performed on-demand. However, adjusting the script to run in such phases is better left for a future improvement. No attempt is done yet to improve failure wrangling (e.g. make the scripts exit more often on errors, which is useful for CI). No attempt is made to run on multiple OS versions or architectures. Fixes #36. --- .github/workflows/build.yml | 39 +++++++++++++++++++++++++ gnustep-web-install | 27 +++++++++++++---- gnustep-web-install-dev | 34 +++++++++++++++------- setup-linux | 58 ++++++++++++++++++++----------------- 4 files changed, 116 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c508341 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +name: Build GNUstep (CI) + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + name: Build using stock script + runs-on: ubuntu-latest + timeout-minutes: 180 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Running only the non-dev version for now, as the dev version assumes + # ssh keys are set up. This should be possible to set up with GitHub + # Actions, but let's keep it simple for now. + - name: Run the script per README instructions (non-dev version) + shell: bash + run: | + # Sourcing so we get the pipefail propagate. + (set -euo pipefail ; export MANAGE_SUDO=no ; . gnustep-web-install) | tee /tmp/gs-build.log + # We should process the log here to see if we can recognize critical + # errors. + + # Otherwise let's see if some expected binaries are present. + if [ ! -x "/usr/local/GNUstep/bin/gnustep-config" ] ; then + echo "gnustep-config not found!" + exit 1 + fi + if [ ! -x "/usr/local/GNUstep/bin/gorm" ] ; then + echo "gorm not found!" + exit 1 + fi diff --git a/gnustep-web-install b/gnustep-web-install index 48b42fa..7be2b92 100755 --- a/gnustep-web-install +++ b/gnustep-web-install @@ -33,14 +33,29 @@ export KERNEL=`uname -s | sed "s/\-.*//g" | awk '{print(tolower($0))}'` echo "Begin setup for ${KERNEL}" export USER=`whoami` -curl -fsSL > ./setup-${KERNEL} https://raw.githubusercontent.com/gnustep/tools-scripts/master/setup-${KERNEL} -. ./setup-${KERNEL} -rm ./setup-${KERNEL} +if [ ! -f ./setup-${KERNEL} ] ; then + # Download the setup script only if not already present (e.g. CI). + curl -fsSL > ./setup-${KERNEL} https://raw.githubusercontent.com/gnustep/tools-scripts/master/setup-${KERNEL} + . ./setup-${KERNEL} + rm ./setup-${KERNEL} +else + # Assume inside CI. + # For CI purposes, default to failing. Using bashism is fine here, for now. + set -euo pipefail + . ./setup-${KERNEL} +fi echo "======== Create gnustep build directories ========" -mkdir -p gnustep -cd gnustep -git clone https://github.com/gnustep/tools-scripts +if [ ! -e .git ] ; then + # Default outside CI. + mkdir -p gnustep + cd gnustep + git clone https://github.com/gnustep/tools-scripts +else + # Inside CI we are already in the repo. + # Just go to the parent directory, tools-scripts will exist. + cd .. +fi ./tools-scripts/clone-essential-repos-https echo "================ Install Dependencies ================" diff --git a/gnustep-web-install-dev b/gnustep-web-install-dev index ff3dd09..c6959be 100755 --- a/gnustep-web-install-dev +++ b/gnustep-web-install-dev @@ -35,20 +35,34 @@ echo " " export KERNEL=`uname -s | sed "s/\-.*//g" | awk '{print(tolower($0))}'` echo "Begin setup for ${KERNEL}" -export USER=`whoami` -if [ "X${KERNEL}" == "Xopenbsd" ];then - ftp -o ./setup-${KERNEL} https://raw.githubusercontent.com/gnustep/tools-scripts/master/setup-${KERNEL} +if [ ! -f ./setup-${KERNEL} ] ; then + # Download the setup script only if not already present (e.g. CI). + export USER=`whoami` + if [ "X${KERNEL}" == "Xopenbsd" ];then + ftp -o ./setup-${KERNEL} https://raw.githubusercontent.com/gnustep/tools-scripts/master/setup-${KERNEL} + else + curl -fsSL > ./setup-${KERNEL} https://raw.githubusercontent.com/gnustep/tools-scripts/master/setup-${KERNEL} + fi + ./setup-${KERNEL} + rm ./setup-${KERNEL} else - curl -fsSL > ./setup-${KERNEL} https://raw.githubusercontent.com/gnustep/tools-scripts/master/setup-${KERNEL} + # Else, assume inside CI. + # For CI purposes, default to failing. Using bashism is fine here, for now. + set -euo pipefail + ./setup-${KERNEL} fi -./setup-${KERNEL} -rm ./setup-${KERNEL} - echo "======== Create gnustep build directories ========" -mkdir -p gnustep -cd gnustep -git clone git@github.com:gnustep/tools-scripts.git +if [ ! -e .git ] ; then + # Default outside CI. + mkdir -p gnustep + cd gnustep + git clone git@github.com:gnustep/tools-scripts.git +else + # Inside CI we are already in the repo. + # Just go to the parent directory, tools-scripts will exist. + cd .. +fi ./tools-scripts/clone-all-repos echo "================ Install Dependencies ================" diff --git a/setup-linux b/setup-linux index b44dd56..d14f098 100755 --- a/setup-linux +++ b/setup-linux @@ -6,37 +6,43 @@ COMMAND="apt" # Add distro specific variables... . /etc/lsb-release -# Install SUDO if needed... -if [ ! -e /usr/bin/sudo ]; then - echo "Installing sudo..." - if [ -e /usr/bin/apt ]; then - su -c "apt install sudo" - +MANAGE_SUDO="${MANAGE_SUDO:-yes}" +if [ "X${MANAGE_SUDO}" != "Xyes" ]; then + # Either CI or user does not want to adjust whether sudo is installed, + # whether root password is set or not, etc. + echo "Skipping sudo management" +else + # Install SUDO if needed... + if [ ! -e /usr/bin/sudo ]; then + echo "Installing sudo..." + if [ -e /usr/bin/apt ]; then + su -c "apt install sudo" + else + su -c "rpm install sudo" + COMMAND="rpm" + fi else - su -c "rpm install sudo" - COMMAND="rpm" + echo "sudo command is already present." fi -else - echo "sudo command is already present." -fi -# Update root password... -echo "Checking if root password is not set, please set it..." -if [ "${DISTRIB_ID}" = "Ubuntu" ]; then - STATUS=`sudo passwd root --status | cut -f2 -d' '` - if [ "${STATUS}" = "L" ]; then - sudo passwd root + # Update root password... + echo "Checking if root password is not set, please set it..." + if [ "${DISTRIB_ID}" = "Ubuntu" ]; then + STATUS=`sudo passwd root --status | cut -f2 -d' '` + if [ "${STATUS}" = "L" ]; then + sudo passwd root + fi fi -fi -# Add to sudoers -if [ "${DISTRIB_ID}" != "Ubuntu" ]; then - if [ ! -e /etc/sudoers.d/${USER} ]; then - echo "Adding ${USER} to sudoers..." - echo "Please enter the root user's password." - su -c 'echo "${USER} ALL=(ALL:ALL) ALL" > /etc/sudoers.d/${USER}' - else - echo "${USER} is already a member of sudo users." + # Add to sudoers + if [ "${DISTRIB_ID}" != "Ubuntu" ]; then + if [ ! -e /etc/sudoers.d/${USER} ]; then + echo "Adding ${USER} to sudoers..." + echo "Please enter the root user's password." + su -c 'echo "${USER} ALL=(ALL:ALL) ALL" > /etc/sudoers.d/${USER}' + else + echo "${USER} is already a member of sudo users." + fi fi fi