X Tutup
Skip to content

Commit 2173996

Browse files
authored
chore: Move from Travis to GitHub Actions (#1836)
1 parent b1f0964 commit 2173996

File tree

7 files changed

+130
-45
lines changed

7 files changed

+130
-45
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh -l
2+
3+
apt-get update && \
4+
apt-get install -y --no-install-recommends \
5+
git \
6+
zip \
7+
curl \
8+
unzip \
9+
wget
10+
11+
curl --silent --show-error https://getcomposer.org/installer | php
12+
php composer.phar self-update
13+
14+
echo "---Installing dependencies ---"
15+
echo "Removing cache/filesystem-adapter for PHP 5.4"
16+
bash -c "if [[ $(php -r 'echo PHP_VERSION;') =~ \"5.4\" ]]; then php composer.phar remove --dev cache/filesystem-adapter; fi"
17+
echo ${composerargs}
18+
php $(dirname $0)/retry.php "php composer.phar update $composerargs"
19+
20+
echo "---Running unit tests ---"
21+
vendor/bin/phpunit

.github/actions/unittest/retry.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
function retry($f, $delay = 10, $retries = 3)
4+
{
5+
try {
6+
return $f();
7+
} catch (Exception $e) {
8+
if ($retries > 0) {
9+
sleep($delay);
10+
return retry($f, $delay, $retries - 1);
11+
} else {
12+
throw $e;
13+
}
14+
}
15+
}
16+
17+
retry(function () {
18+
global $argv;
19+
passthru($argv[1], $ret);
20+
21+
if ($ret != 0) {
22+
throw new \Exception('err');
23+
}
24+
}, 1);

.github/workflows/tests.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Test Suite
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ${{matrix.operating-system}}
11+
strategy:
12+
matrix:
13+
operating-system: [ ubuntu-latest ]
14+
php: [ "5.6", "7.0", "7.1", "7.2", "7.3", "7.4" ]
15+
name: PHP ${{matrix.php }} Unit Test
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: ${{ matrix.php }}
22+
- name: Install Dependencies
23+
uses: nick-invision/retry@v1
24+
with:
25+
timeout_minutes: 10
26+
max_attempts: 3
27+
command: composer install
28+
- name: Run Script
29+
run: vendor/bin/phpunit
30+
# use dockerfiles for oooooolllllldddd versions of php, setup-php times out for those.
31+
test_php55:
32+
name: "PHP 5.5 Unit Test"
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v2
37+
- name: Run Unit Tests
38+
uses: docker://php:5.5-cli
39+
with:
40+
entrypoint: ./.github/actions/unittest/entrypoint.sh
41+
test_php54:
42+
name: "PHP 5.4 Unit Test"
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v2
47+
- name: Run Unit Tests
48+
uses: docker://php:5.4-cli
49+
with:
50+
entrypoint: ./.github/actions/unittest/entrypoint.sh
51+
test_php54_lowest:
52+
name: "PHP 5.4 Unit Test Prefer Lowest"
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v2
57+
- name: Run Unit Tests
58+
uses: docker://php:5.4-cli
59+
env:
60+
composerargs: "--prefer-lowest"
61+
with:
62+
entrypoint: ./.github/actions/unittest/entrypoint.sh
63+
style:
64+
runs-on: ubuntu-latest
65+
name: PHP Style Check
66+
steps:
67+
- uses: actions/checkout@v2
68+
- name: Setup PHP
69+
uses: shivammathur/setup-php@v2
70+
with:
71+
php-version: "7.4"
72+
- name: Install Dependencies
73+
uses: nick-invision/retry@v1
74+
with:
75+
timeout_minutes: 10
76+
max_attempts: 3
77+
command: composer install
78+
- name: Run Script
79+
run: vendor/bin/phpcs src --standard=phpcs.xml.dist -np

.travis.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/googleapis/google-api-php-client.svg?branch=master)](https://travis-ci.org/googleapis/google-api-php-client)
1+
![](https://github.com/googleapis/google-api-php-client/workflows/.github/workflows/tests.yml/badge.svg)
22

33
# Google APIs Client Library for PHP #
44

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"guzzlehttp/psr7": "^1.2"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^4.8|^5.0",
19+
"phpunit/phpunit": "^4.8.36|^5.0",
2020
"squizlabs/php_codesniffer": "~2.3",
2121
"symfony/dom-crawler": "~2.1",
2222
"symfony/css-selector": "~2.1",

tests/Google/ClientTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,9 @@ public function testExecuteSetsCorrectHeaders()
772772
$client->execute($request);
773773
}
774774

775+
/**
776+
* @runInSeparateProcess
777+
*/
775778
public function testClientOptions()
776779
{
777780
// Test credential file
@@ -812,6 +815,7 @@ public function testClientOptions()
812815
]);
813816
$this->assertEquals('some-quota-project', $client->getConfig('quota_project'));
814817
// Test quota project in google/auth dependency
818+
putenv('GOOGLE_APPLICATION_CREDENTIALS='.$tmpCredFile);
815819
$method = new ReflectionMethod($client, 'createApplicationDefaultCredentials');
816820
$method->setAccessible(true);
817821
$credentials = $method->invoke($client);

0 commit comments

Comments
 (0)
X Tutup