feat: Adds ability to download browserstack-local binary #100
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
pull_request: | |
branches: [main] | |
push: | |
branches: [main] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }} | |
jobs: | |
configs: | |
name: Configure | |
uses: creasico/laravel-package/.github/workflows/configure.yml@main | |
secrets: inherit | |
permissions: | |
contents: read | |
pull-requests: write | |
tests: | |
name: Test on PHP ${{ matrix.php }} | |
runs-on: ubuntu-latest | |
needs: configs | |
outputs: | |
has-reports: ${{ steps.reports.outputs.has-reports }} | |
strategy: | |
fail-fast: false | |
matrix: | |
php: ['8.1', '8.2'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP ${{ matrix.php }} | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2 | |
coverage: xdebug | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Cache Composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ needs.configs.outputs.composer-cache }} | |
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer- | |
- name: Install dependencies | |
run: composer update --prefer-dist --no-interaction --no-progress | |
- name: Run tests | |
env: | |
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} | |
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | |
BROWSERSTACK_PROJECT_NAME: ${{ github.repository }} | |
BROWSERSTACK_BUILD_NAME: ${{ github.ref_name }}-${{ github.sha }} | |
run: | | |
composer testbench dusk:browserstack-local | |
composer test -- --coverage | |
- name: Generate reports for CodeClimate | |
if: ${{ github.actor != 'dependabot[bot]' || needs.configs.outputs.should-reports == '1' }} | |
id: reports | |
env: | |
COVERAGE_FILE: tests/reports/clover.xml | |
CODECLIMATE_REPORT: ${{ github.workspace }}/tests/reports/codeclimate.${{ matrix.php }}.json | |
run: | | |
if [[ -n \"$CC_TEST_REPORTER_URL\" ]]; then | |
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter | |
./cc-test-reporter format-coverage -t clover -o $CODECLIMATE_REPORT $COVERAGE_FILE | |
echo "has-reports=1" >> $GITHUB_OUTPUT | |
fi | |
- name: Upload tests reports | |
uses: actions/upload-artifact@v4 | |
if: ${{ github.actor != 'dependabot[bot]' || needs.configs.outputs.should-reports == '1' }} | |
with: | |
name: test-reports-${{ matrix.php }} | |
path: tests/reports | |
reports: | |
name: Report Test Coverages | |
if: ${{ github.actor != 'dependabot[bot]' && needs.tests.outputs.has-reports == '1' }} | |
runs-on: ubuntu-latest | |
needs: tests | |
steps: | |
- name: Download test reports | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: test-reports-* | |
merge-multiple: true | |
- name: Report to CodeClimate | |
run: | | |
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter | |
./cc-test-reporter sum-coverage -o - codeclimate.*.json | ./cc-test-reporter upload-coverage --input - | |