Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix/phpstan-composer
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Nov 4, 2023
2 parents a362d2a + b8fc1d1 commit 933c409
Show file tree
Hide file tree
Showing 57 changed files with 2,299 additions and 243 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
groups:
dependencies:
patterns:
- "*"
51 changes: 49 additions & 2 deletions .github/workflows/composer-root-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Lint CS
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -100,3 +100,50 @@ jobs:
- name: Failing run
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1

update-composer-root-version:
name: Update the Composer root version
if: ${{ github.repository == 'humbug/php-scoper' && github.ref_name == 'main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: '0' # Ensures the tags are fetched
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer
coverage: none

- name: Install the Composer dependencies
uses: ramsey/composer-install@v2
with:
working-directory: 'composer-root-version-checker'

- name: Dump the Composer too version
run: cd composer-root-version-checker; make dump_root_version

- name: Check for changes
run: |
if [ $(git status --porcelain | wc -l) -eq "0" ]; then
echo "🟢 No change detected."
echo "composer_root_version_changed=false" >> $GITHUB_ENV
else
echo "composer_root_version_changed=true" >> $GITHUB_ENV
fi
- name: Create Pull Request
if: env.composer_root_version == 'true'
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch-suffix: random
delete-branch: true
title: "build: Update the Composer root version"
committer: "php-scoper-bot <[email protected]>"
commit-message: "Update the Composer root version"
85 changes: 76 additions & 9 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
types: [ created ]
schedule:
# Do not make it the first of the month and/or midnight since it is a very busy time
- cron: "* 10 5 * *"
- cron: "* 10 5 * *"

# See https://stackoverflow.com/a/72408109
concurrency:
Expand All @@ -27,7 +27,7 @@ jobs:
- '8.2'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -149,6 +149,72 @@ jobs:
- name: Run e2e ${{ matrix.e2e }}
run: make ${{ matrix.e2e }} --debug


# Most of the job definitions come from https://github.com/sebastianbergmann/phpunit/blob/main/.github/workflows/ci.yml#L228
# (job name "test-phar").
test-phpunit-scoping:
runs-on: ubuntu-latest
needs: build-test-phar

env:
PHP_EXTENSIONS: none, curl, dom, json, fileinfo, iconv, libxml, mbstring, phar, soap, tokenizer, xml, xmlwriter
PHP_INI_VALUES: assert.exception=1, phar.readonly=0, zend.assertions=1

strategy:
fail-fast: false
matrix:
php-version:
- '8.2'
coverage:
- xdebug

steps:
- name: Checkout PHPUnit code
uses: actions/checkout@v4
with:
repository: 'sebastianbergmann/phpunit'


- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: ${{ matrix.coverage }}
extensions: ${{ env.PHP_EXTENSIONS }}
ini-values: ${{ env.PHP_INI_VALUES }}
tools: none

- name: Install java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11

- name: Retrieve built PHP-Scoper PHAR
uses: actions/download-artifact@v3
with:
name: php-scoper-phar-${{ matrix.php-version }}
path: bin

# See https://github.com/actions/download-artifact#limitations
# the permissions are not guaranteed to be preserved
- name: Ensure PHAR is executable
run: chmod 755 bin/php-scoper.phar

- name: Make the downloaded PHP-Scoper PHAR the PHPUnit scoper used
run: mv -f bin/php-scoper.phar tools/php-scoper

- name: Check that the PHP-Scoper PHAR works
run: tools/php-scoper --version

- name: Build PHPUnit scoped PHAR
run: ant phar-snapshot

# To keep in sync with e2e.file#e2e_038
- name: Run PHPUnit PHAR-specific tests
run: ant run-phar-specific-tests


# This is a "trick", a meta task which does not change, and we can use in
# the protected branch rules as opposed to the E2E tests one above which
# may change regularly.
Expand All @@ -160,12 +226,13 @@ jobs:
needs:
- build-test-phar
- e2e-tests
- test-phpunit-scoping
if: always()
steps:
- name: Successful run
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Successful run
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0

- name: Failing run
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- name: Failing run
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: CS
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
name: PHPStan
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
95 changes: 91 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
DOCKERFILE: Dockerfile
DOCKERHUB_USERNAME: humbugphp

jobs:
build-phar:
runs-on: ubuntu-latest
name: Build PHAR
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -54,7 +58,7 @@ jobs:

- name: Import GPG key
if: github.event_name == 'release'
uses: crazy-max/ghaction-import-gpg@v5
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_KEY_74A754C9778AA03AA451D1C1A000F927D67184EE }}
passphrase: ${{ secrets.GPG_KEY_74A754C9778AA03AA451D1C1A000F927D67184EE_PASSPHRASE }}
Expand All @@ -71,7 +75,6 @@ jobs:
bin/php-scoper.phar
- name: Upload the PHAR artifact
if: github.event_name == 'release'
uses: actions/upload-artifact@v3
with:
name: php-scoper-phar
Expand All @@ -94,7 +97,91 @@ jobs:
- name: Upload php-scoper.phar
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.PHP_SCOPER_GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
files: |
php-scoper.phar
php-scoper.phar.asc
publish-docker-image:
runs-on: ubuntu-latest
name: Publish the Docker image
needs:
- build-phar
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/download-artifact@v3
with:
name: php-scoper-phar
path: .

# See https://github.com/actions/download-artifact#limitations
# the permissions are not guaranteed to be preserved
- name: Ensure PHAR is executable
run: |
chmod 755 php-scoper.phar
mv -vf php-scoper.phar bin/php-scoper.phar
./bin/php-scoper.phar --ansi --version
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Container Registry
if: github.event_name == 'release'
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Setup the Docker (release) tag(s)
if: github.event_name == 'release'
# Selects a random value for $EOF as a delimiter, and sets the DOCKER_TAGS environment variable
# as a multi-line environment variable.
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "DOCKER_TAGS<<$EOF" >> $GITHUB_ENV
echo "${{ env.DOCKERHUB_USERNAME }}/php-scoper:${{ github.ref_name }}" >> $GITHUB_ENV
echo "${{ env.DOCKERHUB_USERNAME }}/php-scoper:latest" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
echo "DOCKER_TEST_TAG=${{ env.DOCKERHUB_USERNAME }}/php-scoper:latest" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
if: github.event_name != 'release'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup the Docker tag(s)
if: github.event_name != 'release'
run: |
echo "DOCKER_TAGS=ghcr.io/humbugphp/php-scoper" >> $GITHUB_ENV
echo "DOCKER_TEST_TAG=ghcr.io/humbugphp/php-scoper" >> $GITHUB_ENV
- name: Build and export to Docker
uses: docker/build-push-action@v3
with:
context: .
file: ${{ env.DOCKERFILE }}
platforms: linux/amd64
tags: ${{ env.DOCKER_TAGS }}
load: true

- name: Test the (release) image
run: docker run --rm ${{ env.DOCKER_TEST_TAG }} --version

- name: Build and push
if: github.event_name == 'release'
uses: docker/build-push-action@v3
with:
context: .
file: ${{ env.DOCKERFILE }}
platforms: linux/amd64
tags: ${{ env.DOCKER_TAGS }}
push: true
4 changes: 2 additions & 2 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: Check Dependencies
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -33,4 +33,4 @@ jobs:
key: db

- name: Checks dependencies for known vulnerabilities
uses: symfonycorp/security-checker-action@v4
uses: symfonycorp/security-checker-action@v5
6 changes: 3 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
if: github.event_name != 'release' && github.event.action != 'created'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -46,7 +46,7 @@ jobs:
name: Check the Composer package
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -71,7 +71,7 @@ jobs:
- '8.2'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
Loading

0 comments on commit 933c409

Please sign in to comment.