Skip to content

Commit

Permalink
GP-20469 Add CI via GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
pfigel committed Jun 5, 2024
1 parent e4e5f72 commit faf5fe0
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 206 deletions.
197 changes: 0 additions & 197 deletions .circleci/config.yml

This file was deleted.

80 changes: 80 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: "Run unit tests"

on: ["push"]

env:
CIVI_CI_CIVICRM: ${{ vars.CIVI_CI_CIVICRM || '["master"]' }}
CIVI_CI_MYSQL: ${{ vars.CIVI_CI_MYSQL || '["8.0"]' }}
CIVI_CI_OS: ${{ vars.CIVI_CI_OS || '["ubuntu-22.04"]' }}
CIVI_CI_PHP: ${{ vars.CIVI_CI_PHP || '["8.1"]' }}
CIVI_CI_BUILD_TYPE: ${{ vars.CIVI_CI_BUILD_TYPE || '["drupal-clean"]' }}
CIVI_CI_EXCLUDES: ${{ vars.CIVI_CI_EXCLUDES || '' }}

jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}
steps:
- id: setup-matrix
uses: druzsan/setup-matrix@v2
with:
matrix: |
civicrm: ${{ env.CIVI_CI_CIVICRM }}
mysql: ${{ env.CIVI_CI_MYSQL }}
os: ${{ env.CIVI_CI_OS }}
php: ${{ env.CIVI_CI_PHP }}
build-type: ${{ env.CIVI_CI_BUILD_TYPE }}
exclude: ${{ env.CIVI_CI_EXCLUDES }}
run-tests:
needs: setup-matrix
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
runs-on: "${{ matrix.os }}"

services:
mysql:
image: "mysql:${{ matrix.mysql }}"
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
ports:
- "3306:3306"
options: >-
--health-cmd="mysqladmin ping"
--health-interval="10s"
--health-timeout="5s"
--health-retries="3"
steps:
- id: clone-repo
name: "Clone the repository"
uses: "actions/checkout@v3"
with:
ref: "${{ github.ref_name }}"
path: "at.greenpeace.advancedlogtables"
- id: build-ci
uses: greenpeace-cee/civi-ci@main
with:
extension: at.greenpeace.advancedlogtables
civicrm: ${{ matrix.civicrm }}
php: ${{ matrix.php }}
build-type: ${{ matrix.build-type }}
- id: install-extension
name: "Install Extension"
env:
EXT_DIR: ${{ steps.build-ci.outputs.ext-dir }}
run: |
PATH="/home/runner/buildkit/bin:$PATH"
cd "$EXT_DIR"
cp -R "$GITHUB_WORKSPACE/at.greenpeace.advancedlogtables" "$EXT_DIR/at.greenpeace.advancedlogtables"
cv en at.greenpeace.advancedlogtables
- id: run-tests
name: "Run Tests"
env:
EXT_DIR: ${{ steps.build-ci.outputs.ext-dir }}
run: |
PATH="/home/runner/buildkit/bin:$PATH"
cd "$EXT_DIR/at.greenpeace.advancedlogtables"
CIVICRM_UF="UnitTests" phpunit9
12 changes: 6 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0"?>
<phpunit backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/phpunit/bootstrap.php">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/phpunit/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./</directory>
</include>
</coverage>
<testsuites>
<testsuite name="My Test Suite">
<directory>./tests/phpunit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./</directory>
</whitelist>
</filter>
<listeners>
<listener class="Civi\Test\CiviTestListener">
<arguments/>
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/CRM/Advancedlogtables/LogTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @group headless
*/
class CRM_Advancedlogtables_LogTableTest extends \CivixPhar\PHPUnit\Framework\TestCase implements HeadlessInterface, HookInterface, TransactionalInterface {
class CRM_Advancedlogtables_LogTableTest extends \PHPUnit\Framework\TestCase implements HeadlessInterface, HookInterface, TransactionalInterface {
use \Civi\Test\Api3TestTrait;

public function setUpHeadless() {
Expand All @@ -25,12 +25,12 @@ public function setUpHeadless() {
->apply();
}

public function setUp() {
public function setUp(): void {
$this->resetLogging();
parent::setUp();
}

public function tearDown() {
public function tearDown(): void {
parent::tearDown();
}

Expand Down

0 comments on commit faf5fe0

Please sign in to comment.