adding files and pr base picking #199
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
on: [pull_request] | |
jobs: | |
pull-request-ci-job: | |
runs-on: ubuntu-20.04 | |
services: | |
mysql-service: | |
image: mysql:5.7 | |
env: | |
MYSQL_ROOT_PASSWORD: root | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd="mysqladmin ping" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=3 | |
steps: | |
- name: Checkout app code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- uses: shivammathur/setup-php@verbose | |
with: | |
php-version: 8.0 | |
coverage: xdebug | |
env: | |
update: true | |
- name: Install Composer Dependencies | |
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs | |
- name: Prepare Laravel Application | |
run: | | |
cp .env.example .env | |
php artisan key:generate | |
- name: Create test database | |
run: | | |
mysql -uroot -h127.0.0.1 -proot -e 'CREATE DATABASE IF NOT EXISTS test;' | |
- name: Setup Database | |
run: | | |
php artisan migrate --no-interaction -vvv | |
php artisan db:seed | |
- name: Install NPM modules | |
run: npm i | |
- name: Install jest | |
run: npm i -g jest | |
### START Codecov integration ### (Codecov integration - STEP 1) | |
- name: Download Codecov CLI Binary | |
run: curl -Os https://cli.codecov.io/latest/linux/codecov | |
### STEPS below are not required, but are great to have for extra security | |
- name: Verify integrity get GPG | |
run: curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import # One-time step | |
- name: Get SHAsums | |
run: | | |
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM | |
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig | |
## VERIFY integrity ### (Codecov integration - STEP 2) | |
- name: Test Signature | |
run: gpgv codecov.SHA256SUM.sig codecov.SHA256SUM | |
- name: Test SHAsums | |
run: shasum -a 256 -c codecov.SHA256SUM | |
- name: Fix permission | |
run: sudo chmod +x codecov | |
- name: Pick a base for the PR | |
run: ./codecov pr-base-picking -t ${{ secrets.CODECOV_TOKEN }} --base-sha $(git rev-parse origin/main) --pr ${{ github.event.number }} --service github --slug vlad-ko/laravel-stripe-app-gh | |
# RUN tests an upload reports ### (Codecov integration - STEP 3) | |
- name: Run Service Testsuite with Coverage | |
run: vendor/bin/phpunit --testsuite="Services Tests" --coverage-clover=coverage-service.xml | |
- name: Upload Service coverage report | |
run: ./codecov upload-process --disable-search -t ${{ secrets.CODECOV_TOKEN }} -n 'service'-${{ github.run_id }} -F service -f coverage-service.xml | |
- name: Run Controller Testsuite with Coverage | |
run: vendor/bin/phpunit --testsuite="Controllers Tests" --coverage-clover=coverage-controller.xml | |
- name: Upload Controller coverage report | |
run: ./codecov upload-process --disable-search -t ${{ secrets.CODECOV_TOKEN }} -n 'controller'-${{ github.run_id }} -F controller -f coverage-controller.xml | |
- name: Run Unit Testsuite with Coverage and Junit outpu | |
run: vendor/bin/phpunit --testsuite="Unit Tests" --coverage-clover=coverage-unit.xml --log-junit junit-unit.xml | |
- name: Upload unit test coverage report | |
run: ./codecov upload-process --disable-search -t ${{ secrets.CODECOV_TOKEN }} -n 'unit'-${{ github.run_id }} -F unit -f coverage-unit.xml | |
- name: Upload test results to Codecov | |
if: ${{ !cancelled() }} | |
uses: codecov/test-results-action@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: junit-unit.xml | |
- name: Javascript tests using Jest | |
run: npm run test | |
- name: Upload Javascript coverage | |
run: ./codecov upload-process --disable-search -t ${{ secrets.CODECOV_TOKEN }} -n 'javascript'-${{ github.run_id }} -F 'javascript' -f coverage/coverage-final.json | |
- name: Trigger notifications | |
run: ./codecov send-notifications -t ${{ secrets.CODECOV_TOKEN }} | |