-
Notifications
You must be signed in to change notification settings - Fork 13
74 lines (71 loc) · 3.56 KB
/
ALL-testCoverage-codeclimate.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
# Run some PHPUnit tests
name: Test Coverage
on: [push]
env:
PKG_NAME: tripal_blast
MODULES: "tripal_blast"
IMAGE_TAG: drupal10.2.x-dev-php8.2-pgsql16
SIMPLETEST_BASE_URL: "http://localhost"
SIMPLETEST_DB: "pgsql://drupaladmin:drupaldevelopmentonlylocal@localhost/sitedb"
BROWSER_OUTPUT_DIRECTORY: "/var/www/drupal/web/sites/default/files/simpletest"
jobs:
# Job 1: 'build'
run-tests:
# Runner type
runs-on: ubuntu-latest
name: Test Coverage
steps:
# Check out the repo
- name: Checkout Repository
uses: actions/checkout@v4
# Here we pull the development tripaldocker image for this combo in our matrix
- name: Pull TripalDocker Image
run: |
docker pull tripalproject/tripaldocker:$IMAGE_TAG
# Just spin up docker the good ol' fashion way
# mounting our currently checked out package inside the docker container.
- name: Spin up Docker locally
run: |
docker run --publish=80:80 --name=tripaldocker -tid \
--volume=`pwd`:/var/www/drupal/web/modules/contrib/$PKG_NAME tripalproject/tripaldocker:$IMAGE_TAG
# Install the modules
- name: Install our package in Docker
run: |
docker exec tripaldocker service postgresql restart
docker exec tripaldocker drush en $MODULES --yes
# Ensure we have the variables we need.
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
# Prepare for code coverage.
- name: Prepare for Code Coverage
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
docker cp cc-test-reporter tripaldocker:/var/www/drupal/web/modules/contrib/$PKG_NAME
docker exec tripaldocker chmod a+x /var/www/drupal/web/modules/contrib/$PKG_NAME/cc-test-reporter
docker exec --workdir=/var/www/drupal/web/modules/contrib/$PKG_NAME tripaldocker ./cc-test-reporter before-build --debug
# Runs the PHPUnit tests.
# https://github.com/mheap/phpunit-github-actions-printer is used
# to report PHPUnit fails in a meaningful way to github in PRs.
# Stopped using mheap due to warning w/ phpunit8->9
- name: Run Tests for Coverage
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 tripaldocker service postgresql restart
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/$PKG_NAME \
tripaldocker phpunit --coverage-text \
--coverage-clover /var/www/drupal/web/modules/contrib/$PKG_NAME/clover.xml
docker exec tripaldocker ls /var/www/drupal/web/modules/contrib/$PKG_NAME
- name: Publish code coverage to Code Climate
run: |
docker exec --workdir=/var/www/drupal/web/modules/contrib/$PKG_NAME tripaldocker \
git config --global --add safe.directory /var/www/drupal/web/modules/contrib/$PKG_NAME
docker exec --workdir=/var/www/drupal/web/modules/contrib/$PKG_NAME \
tripaldocker ./cc-test-reporter after-build clover.xml \
--id ${{ secrets.CODECLIMATE_TEST_REPORTER_ID }} \
--debug -t clover -p /var/www/drupal/web/modules/contrib/$PKG_NAME