-
Notifications
You must be signed in to change notification settings - Fork 523
124 lines (103 loc) · 3.71 KB
/
Copy pathtest.yml
File metadata and controls
124 lines (103 loc) · 3.71 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Test
on:
pull_request:
push:
branches: master
jobs:
lint:
runs-on: ubuntu-latest
name: Lint
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.5'
extensions: json, mbstring
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- name: Lint the code
run: vendor/bin/parallel-lint --exclude vendor .
- name: Lint composer.json
run: composer validate --strict
detect:
runs-on: ubuntu-latest
name: Detect changed providers
outputs:
providers: ${{ steps.detect.outputs.providers }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Needs history back to the merge base to diff the branch.
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.5'
extensions: json, mbstring
- name: Detect changed providers
id: detect
env:
BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
run: |
# Triple-dot diffs against the merge base, so commits landed on the
# base branch since this one forked are not counted as changes.
providers=$(php tools/changed-providers.php "$BASE_SHA...$HEAD_SHA")
echo "providers=$providers" >> "$GITHUB_OUTPUT"
echo "Testing: $providers"
test:
runs-on: ubuntu-latest
needs: detect
# An empty matrix fails at expansion time, so skip the job entirely.
if: needs.detect.outputs.providers != '[]'
name: Test ${{ matrix.provider }}
strategy:
fail-fast: false
matrix:
provider: ${{ fromJSON(needs.detect.outputs.providers) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.5'
extensions: json, mbstring
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
# Most providers only need the root install, which autoloads every
# src/* class. A handful declare their own third-party dependencies -
# install those so they are tested against what users actually get.
- name: Install provider dependencies
if: matrix.provider != 'all'
env:
PROVIDER: ${{ matrix.provider }}
run: |
# Keep the version constraints, so CI resolves what a user installing
# this provider would actually get.
extra=$(jq -r '.require | to_entries[]
| select(.key | test("^(php|ext-|socialiteproviders/manager$)") | not)
| "\(.key):\(.value)"' "src/$PROVIDER/composer.json")
if [ -n "$extra" ]; then
echo "Installing provider dependencies:"
echo "$extra"
echo "$extra" | tr '\n' '\0' \
| xargs -0 composer require --no-interaction --prefer-dist --update-with-dependencies
else
echo "No extra dependencies."
fi
- name: Run tests
env:
PROVIDER: ${{ matrix.provider }}
run: |
if [ "$PROVIDER" = "all" ]; then
vendor/bin/phpunit --testsuite Providers
else
vendor/bin/phpunit --testsuite Providers --filter "SocialiteProviders\\\\Tests\\\\$PROVIDER\\\\"
fi