-
-
Notifications
You must be signed in to change notification settings - Fork 78
170 lines (148 loc) · 6.53 KB
/
devshop.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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-*