-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
128 lines (128 loc) · 6.6 KB
/
action.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
# action.yml
name: 'Test Tripal Action'
description: 'Run automated testing for a Tripal extension module.'
inputs:
directory-name:
description: "The name of the directory your Tripal module or package was checked out into."
required: true
modules:
description: "A space-separated list of module machine names indicating which modules to install before running tests."
required: true
php-version:
description: "The version of PHP you would like tested. This must match one of the current PHP versions TripalDocker is available in (e.g. 8.0 and 8.1)."
required: false
default: '8.3'
pgsql-version:
description: "The version of PostgreSQL you would like your tests run against. This must match one of the current versions TripalDocker is available in (e.g. 13)."
required: false
default: '16'
drupal-version:
description: "The version of Drupal you would like your tests run against. This must match one of the current versions TripalDocker is available in (e.g. 9.4.x-dev, 9.5.x-dev)."
required: false
default: '10.4.x-dev'
phpunit-command-options:
description: "A string providing any options you would like added to the phpunit command."
required: false
default: ' '
codeclimate-reporter-id:
description: the reporter ID for codeclimate to publish results to. This should be saved as a secret in your reporsitory.
required: false
build-image:
description: "Indicates whether you would like to build the docker based on your code (true) or pull an existing image (false)."
required: true
default: 'false'
dockerfile:
description: "The relative path and file name for the dockerfile to use with build-image."
required: true
default: 'Dockerfile'
runs:
using: "composite"
steps:
# Here we pull the development tripaldocker image for this combo
- name: Pull TripalDocker Image
if: ${{ inputs.build-image == 'false' }}
shell: bash
env:
IMAGE_TAG: "drupal${{ inputs.drupal-version }}-php${{ inputs.php-version }}-pgsql${{ inputs.pgsql-version }}"
run: |
docker pull tripalproject/tripaldocker:$IMAGE_TAG
docker image tag tripalproject/tripaldocker:$IMAGE_TAG testing:localdocker
- name: Build Local Docker Image
if: ${{ inputs.build-image == 'true' }}
shell: bash
run: |
docker build --tag=testing:localdocker \
--build-arg drupalversion="${{ inputs.drupal-version }}" \
--build-arg phpversion="${{ inputs.php-version }}" \
--build-arg postgresqlversion="${{ inputs.pgsql-version }}" \
--build-arg chadoschema='teacup' ./
# Just spin up docker the good ol' fashion way
# mounting our currently checked out package inside the docker container.
- name: Spin up Docker locally
shell: bash
run: |
docker run --publish=80:80 --name=tripaldocker -tid \
--volume=`pwd`:/var/www/drupal/web/modules/contrib/${{ inputs.directory-name }} testing:localdocker
docker exec tripaldocker bash -c "until pg_isready --dbname=sitedb --username=drupaladmin --host=localhost; do sleep 1; done"
# Install the modules
- name: Install our package in Docker
if: "${{ inputs.modules != '' }}"
shell: bash
run: |
docker exec tripaldocker drush en ${{ inputs.modules }} --yes
# If we have codeclimate enabled, then prepare for it here.
- name: Prepare for Codeclimate coverage reporting
if: "${{ inputs.codeclimate-reporter-id != '' }}"
shell: bash
env:
ABSOLUTE_MODULE_PATH: "/var/www/drupal/web/modules/contrib/${{ inputs.directory-name }}"
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
docker cp cc-test-reporter tripaldocker:$ABSOLUTE_MODULE_PATH
docker exec tripaldocker chmod a+x $ABSOLUTE_MODULE_PATH/cc-test-reporter
docker exec --workdir=$ABSOLUTE_MODULE_PATH tripaldocker ./cc-test-reporter before-build --debug
# Runs the PHPUnit tests without coverage.
- name: Run PHPUnit Tests
if: "${{ inputs.codeclimate-reporter-id == '' }}"
shell: bash
env:
SIMPLETEST_BASE_URL: "http://localhost"
SIMPLETEST_DB: "pgsql://drupaladmin:drupaldevelopmentonlylocal@localhost/sitedb"
BROWSER_OUTPUT_DIRECTORY: "/var/www/drupal/web/sites/default/files/simpletest"
run: |
docker exec -e SIMPLETEST_BASE_URL=$SIMPLETEST_BASE_URL \
-e SIMPLETEST_DB=$SIMPLETEST_DB \
-e BROWSER_OUTPUT_DIRECTORY=$BROWSER_OUTPUT_DIRECTORY \
--workdir=/var/www/drupal/web/modules/contrib/${{ inputs.directory-name }} \
tripaldocker phpunit ${{ inputs.phpunit-command-options }}
# Runs the PHPUnit tests WITH coverage.
- name: Run PHPUnit Tests with coverage for CodeClimate
if: "${{ inputs.codeclimate-reporter-id != '' }}"
shell: bash
env:
SIMPLETEST_BASE_URL: "http://localhost"
SIMPLETEST_DB: "pgsql://drupaladmin:drupaldevelopmentonlylocal@localhost/sitedb"
BROWSER_OUTPUT_DIRECTORY: "/var/www/drupal/web/sites/default/files/simpletest"
CODECLIMATE_REPORT: "/var/www/drupal/web/modules/contrib/${{ inputs.directory-name }}/clover.xml"
run: |
docker exec -e SIMPLETEST_BASE_URL=$SIMPLETEST_BASE_URL \
-e SIMPLETEST_DB=$SIMPLETEST_DB \
-e BROWSER_OUTPUT_DIRECTORY=$BROWSER_OUTPUT_DIRECTORY \
--workdir=/var/www/drupal/web/modules/contrib/${{ inputs.directory-name }} \
tripaldocker phpunit ${{ inputs.phpunit-command-options }} \
--coverage-text --coverage-clover $CODECLIMATE_REPORT
docker exec tripaldocker ls /var/www/drupal/web/modules/contrib/${{ inputs.directory-name }}
# Publish to codeclimate
- name: Publish code coverage to Code Climate
if: "${{ inputs.codeclimate-reporter-id != '' }}"
shell: bash
env:
CODECLIMATE_REPORT: "/var/www/drupal/web/modules/contrib/${{ inputs.directory-name }}/clover.xml"
ABSOLUTE_MODULE_PATH: "/var/www/drupal/web/modules/contrib/${{ inputs.directory-name }}"
run: |
docker exec --workdir=$ABSOLUTE_MODULE_PATH tripaldocker \
git config --global --add safe.directory $ABSOLUTE_MODULE_PATH
docker exec --workdir=$ABSOLUTE_MODULE_PATH \
tripaldocker ./cc-test-reporter after-build clover.xml \
--id ${{ inputs.codeclimate-reporter-id }} \
--debug -t clover -p $ABSOLUTE_MODULE_PATH