Skip to content

Issue #0: Max runner disk size hit, try to remove things #184

Issue #0: Max runner disk size hit, try to remove things

Issue #0: Max runner disk size hit, try to remove things #184

Workflow file for this run

name: Bash tests
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clean runner image
run: |
# Runner image is running out of space (14GB), let's try to remove some unused files.
# See https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
echo "Before removing files:"
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "After removing files:"
df -h
- name: Checkout repository
uses: actions/checkout@v2
- name: Add HTTP basic auth credentials
run: |
# Using GitHub repository secret to provide a token for GitHub downloads.
# The secret should named AUTH_JSON_FOR_BOILERPLATE_GITHUB_CI and be like this:
# {
# "github-oauth": {
# "github.com": "<A PERSONAL ACCESS TOKEN>"
# }
# }
echo "auth.json path: $GITHUB_WORKSPACE/auth.json"
echo '${{ secrets.auth_json_for_boilerplate_github_ci }}' > $GITHUB_WORKSPACE/auth.json
pwd
- name: Prepare container for testing
id: testing-container-setup
run: |
ROOT_PATH=/boilerplate_tests
docker_hub_image=metadrop/drupal-boilerplate-dind:v0.3
echo "----- Get image to run the tests -----"
docker pull $docker_hub_image
echo "----- Create a docker container from the downloaded image -----"
CONTAINER_ID=$(docker run -d --privileged --name testrunner --mount type=bind,source=.,target=$ROOT_PATH $docker_hub_image)
echo "----- Container ID is $CONTAINER_ID -----"
sleep 5
docker ps
echo "----- Make docker available for the tester user (dirty trick? How to improve it?) -----"
docker exec $CONTAINER_ID chown :tester /var/run/docker.sock
echo "----- Export container id to other steps -----"
echo "CONTAINER_ID=$CONTAINER_ID" >> "$GITHUB_OUTPUT"
echo "ROOT_PATH=$ROOT_PATH" >> "$GITHUB_OUTPUT"
- name: Prepare shellspec
env:
CONTAINER_ID: ${{ steps.testing-container-setup.outputs.CONTAINER_ID }}
ROOT_PATH: ${{ steps.testing-container-setup.outputs.ROOT_PATH }}
run: |
echo "----- Download and uncompress shellspec, the test framework used for testing -----"
docker exec $CONTAINER_ID wget https://github.com/shellspec/shellspec/releases/download/0.28.1/shellspec-dist.tar.gz -O /opt/shellspec-dist.tar.gz
docker exec $CONTAINER_ID tar xfvz /opt/shellspec-dist.tar.gz -C /opt/
echo "----- Copy shellspec config file to the root folder -----"
ln -s .github/shellspec/shellspec .shellspec
echo "----- Copy shellspec test files -----"
ln -s .github/shellspec/shellspec_spec shellspec_spec
- name: Setup Git cli
run: |
git config --global user.email "test@example.io"
git config --global user.name "CI tester"
- name: Set ownership
run: sudo chown 1000 -R .
- name: Run composer install
env:
CONTAINER_ID: ${{ steps.testing-container-setup.outputs.CONTAINER_ID }}
ROOT_PATH: ${{ steps.testing-container-setup.outputs.ROOT_PATH }}
run: |
docker exec -u tester -w $ROOT_PATH/ $CONTAINER_ID composer install --ignore-platform-reqs
- name: Run boilerplate assistant
env:
CONTAINER_ID: ${{ steps.testing-container-setup.outputs.CONTAINER_ID }}
ROOT_PATH: ${{ steps.testing-container-setup.outputs.ROOT_PATH }}
run: |
docker exec -u tester -w $ROOT_PATH/ $CONTAINER_ID composer boilerplate:assistant
# Because execute in test environment the performance can vary, so let's
# try to not fail randomly because slow test machine.
- name: Lower Lighthouse minimal scores
env:
CONTAINER_ID: ${{ steps.testing-container-setup.outputs.CONTAINER_ID }}
ROOT_PATH: ${{ steps.testing-container-setup.outputs.ROOT_PATH }}
run: |
# Modify the minimal scores.
docker exec -u tester -w $ROOT_PATH/ $CONTAINER_ID sed -i "s/0\.9/0\.75/" tests/functional/lighthouse/lighthouserc.js
# Restart lighthouse container so it uses the new file. It is not
# possible to copy the file inside the container because docker
# forbids writting to it (probably because some docker dark magic).
docker exec -u tester -w $ROOT_PATH/ $CONTAINER_ID docker compose restart lighthouse
- name: Run tests
env:
CONTAINER_ID: ${{ steps.testing-container-setup.outputs.CONTAINER_ID }}
ROOT_PATH: ${{ steps.testing-container-setup.outputs.ROOT_PATH }}
run: |
docker exec -u tester -w $ROOT_PATH/ $CONTAINER_ID /opt/shellspec/shellspec