Skip to content

Commit aad17bb

Browse files
authored
Limit CI workflows to supported branches (#3411)
* Fix YAML indentation * Limit CI workflows to supported branches * Run CI for feature branches
1 parent 3a7443f commit aad17bb

File tree

5 files changed

+222
-197
lines changed

5 files changed

+222
-197
lines changed

.github/workflows/build-ci-atlas.yml

Lines changed: 91 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,100 @@
11
name: "Atlas CI"
22

33
on:
4-
push:
5-
pull_request:
4+
push:
5+
branches:
6+
- "[0-9]+.[0-9x]+"
7+
- "feature/*"
8+
pull_request:
9+
branches:
10+
- "[0-9]+.[0-9x]+"
11+
- "feature/*"
612

713
env:
814
MONGODB_EXT_V1: mongodb-1.21.0
915
MONGODB_EXT_V2: stable
1016

1117
jobs:
12-
build:
13-
runs-on: "${{ matrix.os }}"
14-
15-
name: "PHP/${{ matrix.php }} Laravel/${{ matrix.laravel }} Driver/${{ matrix.driver }}"
16-
17-
strategy:
18-
matrix:
19-
os:
20-
- "ubuntu-latest"
21-
php:
22-
- "8.2"
23-
- "8.3"
24-
- "8.4"
25-
laravel:
26-
- "11.*"
27-
- "12.*"
28-
driver:
29-
- 1
30-
include:
31-
- php: "8.4"
32-
laravel: "12.*"
33-
os: "ubuntu-latest"
34-
driver: 2
35-
36-
steps:
37-
- uses: "actions/checkout@v4"
38-
39-
- name: "Create MongoDB Atlas Local"
40-
run: |
41-
docker run --name mongodb -p 27017:27017 --detach mongodb/mongodb-atlas-local:latest
42-
until docker exec --tty mongodb mongosh --eval "db.runCommand({ ping: 1 })"; do
43-
sleep 1
44-
done
45-
until docker exec --tty mongodb mongosh --eval "db.createCollection('connection_test') && db.getCollection('connection_test').createSearchIndex({mappings:{dynamic: true}})"; do
46-
sleep 1
47-
done
48-
49-
- name: "Show MongoDB server status"
50-
run: |
51-
docker exec --tty mongodb mongosh --eval "db.runCommand({ serverStatus: 1 })"
52-
53-
- name: Setup cache environment
54-
id: extcache
55-
uses: shivammathur/cache-extensions@v1
56-
with:
57-
php-version: ${{ matrix.php }}
58-
extensions: ${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
59-
key: "extcache-v1"
60-
61-
- name: "Installing php"
62-
uses: "shivammathur/setup-php@v2"
63-
with:
64-
php-version: ${{ matrix.php }}
65-
extensions: "curl,mbstring,xdebug,${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}"
66-
coverage: "xdebug"
67-
tools: "composer"
68-
69-
- name: "Show Docker version"
70-
if: ${{ runner.debug }}
71-
run: "docker version && env"
72-
73-
- name: "Restrict Laravel version"
74-
run: "composer require --dev --no-update 'laravel/framework:${{ matrix.laravel }}'"
75-
76-
- name: "Download Composer cache dependencies from cache"
77-
id: "composer-cache"
78-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
79-
80-
- name: "Cache Composer dependencies"
81-
uses: "actions/cache@v4"
82-
with:
83-
path: ${{ steps.composer-cache.outputs.dir }}
84-
key: "${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }}"
85-
restore-keys: "${{ matrix.os }}-composer-"
86-
87-
- name: "Install dependencies"
88-
run: |
89-
composer update --no-interaction
90-
91-
- name: "Run tests"
92-
run: |
93-
export MONGODB_URI="mongodb://127.0.0.1:27017/?directConnection=true"
94-
php -d zend.assertions=1 ./vendor/bin/phpunit --coverage-clover coverage.xml --group atlas-search
18+
build:
19+
runs-on: "${{ matrix.os }}"
20+
21+
name: "PHP/${{ matrix.php }} Laravel/${{ matrix.laravel }} Driver/${{ matrix.driver }}"
22+
23+
strategy:
24+
matrix:
25+
os:
26+
- "ubuntu-latest"
27+
php:
28+
- "8.2"
29+
- "8.3"
30+
- "8.4"
31+
laravel:
32+
- "11.*"
33+
- "12.*"
34+
driver:
35+
- 1
36+
include:
37+
- php: "8.4"
38+
laravel: "12.*"
39+
os: "ubuntu-latest"
40+
driver: 2
41+
42+
steps:
43+
- uses: "actions/checkout@v4"
44+
45+
- name: "Create MongoDB Atlas Local"
46+
run: |
47+
docker run --name mongodb -p 27017:27017 --detach mongodb/mongodb-atlas-local:latest
48+
until docker exec --tty mongodb mongosh --eval "db.runCommand({ ping: 1 })"; do
49+
sleep 1
50+
done
51+
until docker exec --tty mongodb mongosh --eval "db.createCollection('connection_test') && db.getCollection('connection_test').createSearchIndex({mappings:{dynamic: true}})"; do
52+
sleep 1
53+
done
54+
55+
- name: "Show MongoDB server status"
56+
run: |
57+
docker exec --tty mongodb mongosh --eval "db.runCommand({ serverStatus: 1 })"
58+
59+
- name: Setup cache environment
60+
id: extcache
61+
uses: shivammathur/cache-extensions@v1
62+
with:
63+
php-version: ${{ matrix.php }}
64+
extensions: ${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
65+
key: "extcache-v1"
66+
67+
- name: "Installing php"
68+
uses: "shivammathur/setup-php@v2"
69+
with:
70+
php-version: ${{ matrix.php }}
71+
extensions: "curl,mbstring,xdebug,${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}"
72+
coverage: "xdebug"
73+
tools: "composer"
74+
75+
- name: "Show Docker version"
76+
if: ${{ runner.debug }}
77+
run: "docker version && env"
78+
79+
- name: "Restrict Laravel version"
80+
run: "composer require --dev --no-update 'laravel/framework:${{ matrix.laravel }}'"
81+
82+
- name: "Download Composer cache dependencies from cache"
83+
id: "composer-cache"
84+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
85+
86+
- name: "Cache Composer dependencies"
87+
uses: "actions/cache@v4"
88+
with:
89+
path: ${{ steps.composer-cache.outputs.dir }}
90+
key: "${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }}"
91+
restore-keys: "${{ matrix.os }}-composer-"
92+
93+
- name: "Install dependencies"
94+
run: |
95+
composer update --no-interaction
96+
97+
- name: "Run tests"
98+
run: |
99+
export MONGODB_URI="mongodb://127.0.0.1:27017/?directConnection=true"
100+
php -d zend.assertions=1 ./vendor/bin/phpunit --coverage-clover coverage.xml --group atlas-search

0 commit comments

Comments
 (0)