Skip to content

DevShop

DevShop #4506

Workflow file for this run

name: DevShop
on:
push:
branches: 1.x
pull_request:
types: [opened, synchronize]
schedule:
- cron: "0 0 * * *"
- cron: "0 12 * * *"
env:
# Set ANSIBLE_VERBOSITY to 1,2 or 3 when needed for development.
ANSIBLE_VERBOSITY: 0
DEBUG_COMMAND: "docker-compose exec -T devshop.server systemctl status --no-pager"
GITHUB_TOKEN: ${{ secrets.INPUT_GITHUB_TOKEN }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha }}
GITHUB_RUN_LOG_URL: https://github.com/opendevshop/devshop/actions/runs/${{ github.run_id }}
DEVSHOP_TESTS_ARTIFACTS_PATH: "/usr/share/devshop/.github/test-artifacts"
COMMAND: "echo 'DevShop Server Online, launched by GitHub Actions.'"
DEVSHOP_DOCKER_COMMAND_RUN: "echo 'Skipping DEVSHOP_DOCKER_COMMAND_RUN (ansible-playbook), so that GitHub Actions can run in a separate step.'"
DOCKER_COMMAND_POST: "echo 'GitHub Actions Container was launched.'"
# Load vars from the vars.ci.yml file.
ANSIBLE_PLAYBOOK_COMMAND_OPTIONS_ARG: "--extra-vars=@/usr/share/devshop/vars.ci.yml"
ANSIBLE_PLAYBOOK_COMMAND_OPTIONS: "--extra-vars=@/usr/share/devshop/vars.ci.yml"
GIT_REF: 1.x
# Prevents including docker-compose.override, which is for local development.
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml
jobs:
docker:
name: "${{ matrix.action }} PHP ${{ matrix.php }}"
# description: Build every docker container, then install DevShop to confirm they work.
strategy:
fail-fast: false
matrix:
php:
# @TODO: Container builds are failing due to ubuntu 18 EOL. Once builds on 20 + 22 work, put these tests back in place.
# - '7.4'
- '8.0'
# - '8.1'
action:
# - Build
- Test
os:
# - 'ubuntu1804'
- 'ubuntu2004'
env:
OS: "${{ matrix.os }}"
#DEVSHOP_DOCKER_IMAGE: "devshop/server:php${{ matrix.php }}"
DEVSHOP_DOCKER_IMAGE: "devshop/server:latest"
HOSTNAME: "devshop.${{ github.event.pull_request.number }}.${{ matrix.os }}.actions.github.com"
ANSIBLE_EXTRA_VARS: "php_version=${{ matrix.php }}"
runs-on: ubuntu-20.04
steps:
# By default, actions/checkout uses the current SHA for the branch it is testing. See on.push.branches: 1.x
# https://github.com/opendevshop/devshop/runs/1517209717?check_suite_focus=true#step:2:465
# For Pull Requests, actions/checkout will use a Merge SHA by default.
# This code sets ref to the PR head SHA instead, so it matches what developers see.
- name: Check Out Sourcecode
uses: actions/checkout@v2
if: github.event_name!='pull_request'
# Fetch all branches and tags so composer can resolve the version.
- name: Check Out Pull Request Sourcecode
uses: actions/checkout@v2
if: github.event_name=='pull_request'
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
# github.ref_name is the branch name on branch builds.
# On PRs ref_name is `PR#/merge`.
- name: Prepare Non Pull Request-only environment
if: github.event_name!='pull_request'
run: |
echo "php_version: '${{ matrix.php }}'" >> vars.ci.yml
echo "devshop_version: ${{ github.ref_name }}" >> vars.ci.yml
echo "aegir_user_uid: 1001" >> vars.ci.yml
echo "aegir_user_gid: 1001" >> vars.ci.yml
# github.head_ref is the PR branch name.
- name: Prepare Pull Request-only environment
if: github.event_name=='pull_request'
run: |
echo "php_version: '${{ matrix.php }}'" >> vars.ci.yml
echo "devshop_version: ${{ github.head_ref }}" >> vars.ci.yml
echo "devshop_cli_repo: ${{ github.event.pull_request.head.repo.clone_url }}" >> vars.ci.yml
- name: Prepare Pull Request-only environment
if: github.event_name=='pull_request'
run: |
echo "GIT_REF=${{ github.head_ref }}" >> $GITHUB_ENV
git switch --create ${{ github.head_ref }}
chmod 777 ./.github/test-artifacts
- name: "vars.ci.yml"
run: cat vars.ci.yml
# Build "devshop.server"
- name: "Build devshop/server:php${{ matrix.php }}"
working-directory: docker
run: docker-compose build
if: matrix.action == 'Build'
- name: "Pull devshop/server:latest"
working-directory: docker
run: docker-compose pull
if: matrix.action == 'Test'
# Launch Container
- name: "Launch devshop/server:latest container"
working-directory: docker
run: |
docker-compose up --detach
sleep 3
docker-compose logs
docker-compose exec -T devshop.server /usr/share/devshop/scripts/devshop-logo "GitHub Actions Container populated with code. Running SHA ${GITHUB_PR_SHA}"
- name: "Git Status"
working-directory: docker
run: git status
- name: "Review Container Environment"
working-directory: docker
run: |
docker-compose ps -a
docker ps -a
docker inspect docker_devshop.server_1
docker-compose exec -T devshop.server env
docker-compose exec -T devshop.server systemctl status --no-pager
sleep 4
- name: "Install DevShop (devshop.server/play.yml --tags=runtime)"
working-directory: docker
# Since the container is launched with a new DEVSHOP_DOCKER_COMMAND_RUN, run the default.
run: |
docker-compose exec -T devshop.server bash -c '${DEFAULT_DEVSHOP_DOCKER_COMMAND_RUN}'
# docker-compose exec -T devshop.remote bash -c '${DEFAULT_DEVSHOP_DOCKER_COMMAND_RUN}'
- name: "Test DevShop"
working-directory: docker
run: docker-compose exec -T --user aegir devshop.server /usr/share/devshop/tests/devshop-tests.sh
- name: Save Docker Logs as Artifacts
working-directory: docker
if: always()
run: |
docker ps -a > ../.github/test-artifacts/artifact-docker-ps.log && \
$DEBUG_COMMAND > ../.github/test-artifacts/artifact-debug-command-output.log && \
docker-compose logs > ../.github/test-artifacts/artifact-docker-compose.log
- name: Upload Test Artifacts
uses: actions/upload-artifact@v2
if: always()
with:
name: TestFailures
path: ./.github/test-artifacts
# - name: Upload Log Artifacts
# uses: actions/upload-artifact@v2
# if: always()
# with:
# name: DockerLogs
# path: artifact-*