Skip to content

Commit

Permalink
only run unit test for PR (#27)
Browse files Browse the repository at this point in the history
* only run unit test for PR

* update
  • Loading branch information
norbybaru authored Sep 14, 2023
1 parent e084710 commit 2af210c
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 20 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Main Build

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

strategy:
fail-fast: false
matrix:
php: [8.0, 8.1]
laravel: [8.*, 9.*, 10.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 8.*
testbench: ^6.0
exclude:
- laravel: 10.*
php: 8.0

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ vars.AWS_ASSUME_ROLE }}
aws-region: eu-west-1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{matrix.php}}

- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Run PHPUnit tests
run: composer test
21 changes: 3 additions & 18 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
name: Run Unit Tests

on:
pull_request:
branches:
- main
push:
branches:
- main
on: pull_request

jobs:
build:
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read

strategy:
fail-fast: false
Expand All @@ -35,12 +25,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ vars.AWS_ASSUME_ROLE }}
aws-region: eu-west-1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -65,4 +49,5 @@ jobs:
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Run PHPUnit tests
run: composer test
run: vendor/bin/phpunit --testsuite Unit

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ public function ingest(TimestreamService $timestreamService)
}
```

# Run Unit Test
```bash
composer test
```

# Online Resources
- https://docs.aws.amazon.com/timestream/latest/developerguide/what-is-timestream.html

7 changes: 5 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit 2af210c

Please sign in to comment.