Skip to content

Commit 585e4d8

Browse files
committed
fix: melhoria e correções ci-tests
1 parent 4f601a6 commit 585e4d8

1 file changed

Lines changed: 64 additions & 7 deletions

File tree

.github/workflows/ci-tests.yml

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ on:
99
permissions:
1010
contents: read
1111

12+
env:
13+
# pin a Code Climate test-reporter release to avoid "latest" redirects returning HTML
14+
CC_TEST_REPORTER_VERSION: v0.11.1
15+
1216
jobs:
1317

1418
phpunit:
15-
1619
runs-on: ubuntu-latest
17-
1820
env:
1921
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_ID }}
2022

2123
steps:
2224
- uses: actions/checkout@v3
23-
- uses: actions/checkout@master
2425

2526
- name: Setup PHP
2627
uses: shivammathur/setup-php@v2
@@ -31,13 +32,69 @@ jobs:
3132
- name: Install Composer Dependencies
3233
run: composer install --no-progress --prefer-dist --optimize-autoloader
3334

34-
- name: Code Climate Setup
35+
- name: Download Code Climate test-reporter
3536
run: |
36-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter && chmod +x ./cc-test-reporter
37-
./cc-test-reporter before-build
37+
set -euo pipefail
38+
echo "Downloading test-reporter from CodeClimate v${CC_TEST_REPORTER_VERSION}"
39+
curl -fsSL "https://github.com/codeclimate/test-reporter/releases/download/${CC_TEST_REPORTER_VERSION}/artifacts.tar.gz" -o artifacts.tar.gz || { echo "curl failed"; exit 1; }
40+
# Extract the linux-amd64 binary from the artifacts
41+
tar -xf artifacts.tar.gz ./artifacts/bin/test-reporter-${CC_TEST_REPORTER_VERSION#v}-linux-amd64
42+
mv ./artifacts/bin/test-reporter-${CC_TEST_REPORTER_VERSION#v}-linux-amd64 ./cc-test-reporter
43+
chmod +x ./cc-test-reporter
44+
rm -rf artifacts.tar.gz artifacts/
45+
# Verify the binary works
46+
./cc-test-reporter --version
47+
48+
- name: Check CodeClimate Configuration
49+
run: |
50+
if [ -z "${{ env.CC_TEST_REPORTER_ID }}" ]; then
51+
echo "WARNING: CC_TEST_REPORTER_ID is not set. CodeClimate reporting will be skipped."
52+
else
53+
echo "CodeClimate Reporter ID is configured (length: ${#CC_TEST_REPORTER_ID})"
54+
fi
55+
56+
- name: Code Climate before-build
57+
if: env.CC_TEST_REPORTER_ID != ''
58+
run: |
59+
echo "Initializing CodeClimate test reporter..."
60+
./cc-test-reporter before-build || {
61+
echo "CodeClimate before-build failed, but continuing..."
62+
exit 0
63+
}
64+
3865
- name: Run Tests
3966
run: |
4067
php vendor/bin/phpunit --color --testdox --coverage-clover clover.xml tests
68+
echo "TEST_EXIT_CODE=$?" >> $GITHUB_ENV
69+
70+
- name: Verify coverage file
71+
run: |
72+
if [ -f clover.xml ]; then
73+
echo "Coverage file generated successfully"
74+
ls -la clover.xml
75+
head -5 clover.xml
76+
else
77+
echo "Coverage file not found!"
78+
exit 1
79+
fi
80+
4181
- name: Send Report
82+
if: env.CC_TEST_REPORTER_ID != ''
4283
run: |
43-
./cc-test-reporter after-build -t clover --exit-code $?
84+
if [ -f clover.xml ]; then
85+
echo "Sending coverage report to CodeClimate..."
86+
echo "File size: $(wc -l < clover.xml) lines"
87+
echo "Exit code: $TEST_EXIT_CODE"
88+
89+
# Enable debug mode to see what's happening
90+
./cc-test-reporter after-build -d -t clover --exit-code $TEST_EXIT_CODE || {
91+
echo "CodeClimate upload failed. This might be due to:"
92+
echo "1. Invalid CC_TEST_REPORTER_ID"
93+
echo "2. Network issues"
94+
echo "3. CodeClimate API problems"
95+
echo "Continuing without failing the build..."
96+
exit 0
97+
}
98+
else
99+
echo "No coverage file found, skipping CodeClimate report"
100+
fi

0 commit comments

Comments
 (0)