-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (87 loc) · 3.59 KB
/
tests.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
###############################################################################
# Sobre o GitHub Actions #
# https://docs.github.com/en/actions/learn-github-actions #
# https://www.youtube.com/watch?v=TLB5MY9BBa4 #
###############################################################################
#
# Testes unitários, funcionais e cobertura de código.
# PestPhp: https://pestphp.com/docs/installation
#
# A taxa de cobertura é gerada e enviada para o serviço de análise de código
# 'Code Climate' apenas quando executado no ubuntu-latest e no php version 8.1
#
# - Sobre: https://codeclimate.com/
# - Como fazer o upload: https://docs.codeclimate.com/docs/github-actions-test-coverage
name: Testes unitários e funcionais
on: ["workflow_dispatch", "push", "pull_request"]
concurrency:
group: testes-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.1]
stability: [prefer-stable]
node: [18]
name: PHP${{ matrix.php }} - STB${{ matrix.stability }} - OS${{ matrix.os }} - NODE${{ matrix.node }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup MySql
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE site;' -uroot -proot
mysql -e 'SHOW DATABASES;' -uroot -proot
mysql -V
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Setup PHP with coverage
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: bcmath, ctype, curl, dom, fileinfo, filter, json, libxml, mbstring, openssl, pcre, pdo, pdo_mysql, phar, tokenizer, xml, xmlreader, xmlwriter
tools: composer:v2
coverage: xdebug
- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
# Gera o arquivo .env baseado no .env.example
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install composer dependencies
run: composer update --${{ matrix.stability }} --prefer-stable --no-interaction --no-progress
# Gera a chave da aplicação
- name: Generate key
run: php artisan key:generate
# Concede full control na pasta de cache da aplicação
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache public
- name: Install npm dependencies and public assets
run: |
npm install
npm run build
- name: Execute tests with coverage
run: ./vendor/bin/pest -d memory_limit=2048M --coverage --colors=always --stop-on-failure
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github.actor) }}
run: echo "$GITHUB_CONTEXT"
- name: Upload coverage to Code Climate
if: ${{ github.actor != 'dependabot[bot]' }}
uses: paambaati/codeclimate-action@v4.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.ARQJUD_CC_TEST_REPORTER_ID }}
with:
debug: true