Skip to content

Commit 4e77bac

Browse files
authored
Re-use built artefact for end-to-end tests (#560)
1 parent 4ade92b commit 4e77bac

File tree

6 files changed

+114
-36
lines changed

6 files changed

+114
-36
lines changed
File renamed without changes.

.github/workflows/build.yml renamed to .github/workflows/build.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ jobs:
4343
- name: Build PHAR
4444
run: make build
4545

46-
- uses: actions/upload-artifact@v1
46+
# Smoke test
47+
- name: Ensure the PHAR works
48+
run: bin/php-scoper.phar --version
49+
50+
- uses: actions/upload-artifact@v2
4751
name: Upload the PHAR artifact
4852
with:
49-
name: php-scoper.phar
53+
name: php-scoper-phar
5054
path: bin/php-scoper.phar
5155

5256
publish-phar:
@@ -56,13 +60,13 @@ jobs:
5660
- 'build-phar'
5761
if: github.event_name == 'release'
5862
steps:
59-
- uses: actions/download-artifact@v1
63+
- uses: actions/download-artifact@v2
6064
with:
61-
name: php-scoper.phar
65+
name: php-scoper-phar
6266
path: .
6367

6468
- name: Upload php-scoper.phar
65-
uses: actions/upload-release-asset@v1
69+
uses: actions/upload-release-asset@v2
6670
env:
6771
GITHUB_TOKEN: ${{ secrets.PHP_SCOPER_GITHUB_TOKEN }}
6872
with:

.github/workflows/tests.yml renamed to .github/workflows/e2e-tests.yaml

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests
1+
name: End-to-End Tests
22

33
on:
44
push:
@@ -8,32 +8,9 @@ on:
88
types: [ created ]
99

1010
jobs:
11-
root-version:
11+
build-test-phar:
1212
runs-on: ubuntu-latest
13-
name: Check COMPOSER_ROOT_VERSION value
14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
php: [ '8.1' ]
18-
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v2
21-
with:
22-
fetch-depth: 0
23-
24-
- name: Setup PHP
25-
uses: shivammathur/setup-php@v2
26-
with:
27-
php-version: ${{ matrix.php }}
28-
tools: composer
29-
coverage: none
30-
31-
- name: Check COMPOSER_ROOT_VERSION
32-
run: make check-composer-root-version
33-
34-
unit-tests:
35-
runs-on: ubuntu-latest
36-
name: Unit tests (PHP ${{ matrix.php }})
13+
name: Build (test) PHAR
3714
strategy:
3815
fail-fast: false
3916
matrix:
@@ -51,6 +28,7 @@ jobs:
5128
uses: shivammathur/setup-php@v2
5229
with:
5330
php-version: ${{ matrix.php }}
31+
ini-values: phar.readonly=0
5432
tools: composer
5533
coverage: none
5634

@@ -65,12 +43,23 @@ jobs:
6543
with:
6644
composer-options: '--prefer-dist'
6745

68-
- name: Run tests
69-
run: make tu
46+
- name: Build PHAR
47+
run: make build
48+
49+
# Smoke test
50+
- name: Ensure the PHAR works
51+
run: bin/php-scoper.phar --version
52+
53+
- uses: actions/upload-artifact@v2
54+
name: Upload the PHAR artifact
55+
with:
56+
name: php-scoper-phar-${{ matrix.php }}
57+
path: bin/php-scoper.phar
7058

7159
e2e-tests:
72-
runs-on: ubuntu-latest
7360
name: 'e2e Test ${{ matrix.e2e }} (PHP: ${{ matrix.php }})'
61+
runs-on: ubuntu-latest
62+
needs: build-test-phar
7463
strategy:
7564
fail-fast: false
7665
matrix:
@@ -127,6 +116,23 @@ jobs:
127116
with:
128117
composer-options: '--prefer-dist'
129118

119+
- name: Retrieve built PHAR
120+
uses: actions/download-artifact@v2
121+
with:
122+
name: php-scoper-phar-${{ matrix.php }}
123+
path: bin
124+
125+
- name: Ensure PHAR will not be rebuilt
126+
run: touch -c bin/php-scoper.phar
127+
128+
# See https://github.com/actions/download-artifact#limitations
129+
# the permissions are not guaranteed to be preserved
130+
- name: Ensure PHAR is executable
131+
run: chmod 755 bin/php-scoper.phar
132+
133+
- name: Check that the PHAR works
134+
run: bin/php-scoper.phar --version
135+
130136
- name: Install tree
131137
if: matrix.e2e == 'e2e_032'
132138
run: sudo apt-get install -y tree
File renamed without changes.

.github/workflows/tests.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
release:
8+
types: [ created ]
9+
10+
jobs:
11+
root-version:
12+
runs-on: ubuntu-latest
13+
name: Check COMPOSER_ROOT_VERSION value
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
php: [ '8.1' ]
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php }}
28+
tools: composer
29+
coverage: none
30+
31+
- name: Check COMPOSER_ROOT_VERSION
32+
run: make check-composer-root-version
33+
34+
unit-tests:
35+
runs-on: ubuntu-latest
36+
name: Unit tests (PHP ${{ matrix.php }})
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
php:
41+
- '7.4'
42+
- '8.0'
43+
- '8.1'
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v2
47+
with:
48+
fetch-depth: 0
49+
50+
- name: Setup PHP
51+
uses: shivammathur/setup-php@v2
52+
with:
53+
php-version: ${{ matrix.php }}
54+
tools: composer
55+
coverage: none
56+
57+
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
58+
- name: Configure composer root version
59+
run: |
60+
source .composer-root-version
61+
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
62+
63+
- name: Install Composer dependencies
64+
uses: ramsey/composer-install@v1
65+
with:
66+
composer-options: '--prefer-dist'
67+
68+
- name: Run tests
69+
run: make tu

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ MAKEFLAGS += --no-builtin-rules
77
PHPBIN=php
88
PHPNOGC=php -d zend.enable_gc=0
99
IS_PHP8=$(shell php -r "echo version_compare(PHP_VERSION, '8.0.0', '>=') ? 'true' : 'false';")
10-
10+
PHPSCOPER=bin/php-scoper.phar
1111
SRC_FILES=$(shell find bin/ src/ -type f)
1212

1313
.PHONY: help
@@ -88,7 +88,6 @@ tm: clover.xml
8888
e2e: ## Run end-to-end tests
8989
e2e: e2e_004 e2e_005 e2e_011 e2e_013 e2e_014 e2e_015 e2e_016 e2e_017 e2e_018 e2e_019 e2e_020 e2e_021 e2e_022 e2e_023 e2e_024 e2e_025 e2e_026 e2e_027 e2e_028 e2e_029 e2e_030 e2e_031 e2e_032
9090

91-
PHPSCOPER=bin/php-scoper.phar
9291

9392
.PHONY: e2e_004
9493
e2e_004: ## Run end-to-end tests for the fixture set 004 — Source code case

0 commit comments

Comments
 (0)