Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add justfile, remove coveralls, and fix AUTOLOAD in CI #1801

Merged
merged 16 commits into from
Jan 9, 2025
Merged
32 changes: 10 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,14 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "8.2"

steps:
- uses: extractions/setup-just@v2
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
php-version: "8.2"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're not running phpstan across multiple PHP versions, I just hardcoded the value we're using


- name: Get Composer Cache Directory
id: composer-cache
Expand All @@ -69,19 +65,17 @@ jobs:
run: composer install --prefer-dist --no-progress

- name: Run phpstan
run: make phpstan
run: just lint

tests:
name: Tests

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
env:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this never worked as intended: env doesn't actually set the environment, it just sets a github variable called env

- AUTOLOAD=0
- AUTOLOAD=1
autoload:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because just recipes can take arguments, we can replace the env-looking value with the actual value we want and pass it in directly

- "0"
- "1"
php-version:
- "5.6"
- "7.0"
Expand All @@ -92,15 +86,16 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
name: Tests (php@${{ matrix.php-version }}, AUTOLOAD=${{ matrix.autoload }})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will show a nicer name now that we're not using the full AUTOLOAD string


steps:
- uses: extractions/setup-just@v2
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: xdebug

- name: Get Composer Cache Directory
id: composer-cache
Expand All @@ -125,17 +120,10 @@ jobs:
- uses: stripe/openapi/actions/stripe-mock@master

- name: Run test suite
# --yes skips the confirmation dialogue for the CI test, which modifies files
run: |
php --version
make ci-test

- name: Coveralls
if: matrix.php-version == '8.2' && matrix.env == 'AUTOLOAD=1'
uses: coverallsapp/github-action@v2
with:
files: clover.xml
flag-name: php-${{ matrix.php-version }}-${{ matrix.env }}
github-token: ${{ secrets.GITHUB_TOKEN }}
just --yes ci-test ${{ matrix.autoload }}

publish:
# Doesn't actually publish. The publish happens via a packagist webhook configured in the Github UI. But we still display a message here
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ build/*
# If the vendor directory isn't being commited the composer.lock file should also be ignored
composer.lock

# Ignore PHPUnit coverage file
clover.xml

# Ignore IDE's configuration files
.idea

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# NOTE: this file is deprecated and slated for deletion; prefer using the equivalent `just` commands.

export PHPDOCUMENTOR_VERSION := v3.0.0

vendor: composer.json
Expand All @@ -12,6 +14,7 @@ test: vendor
.PHONY: test

ci-test: vendor
echo "calling build with $$AUTOLOAD"
./build.php $$AUTOLOAD
.PHONY: ci-test

Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[![Latest Stable Version](https://poser.pugx.org/stripe/stripe-php/v/stable.svg)](https://packagist.org/packages/stripe/stripe-php)
[![Total Downloads](https://poser.pugx.org/stripe/stripe-php/downloads.svg)](https://packagist.org/packages/stripe/stripe-php)
[![License](https://poser.pugx.org/stripe/stripe-php/license.svg)](https://packagist.org/packages/stripe/stripe-php)
[![Code Coverage](https://coveralls.io/repos/stripe/stripe-php/badge.svg?branch=master)](https://coveralls.io/r/stripe/stripe-php?branch=master)

The Stripe PHP library provides convenient access to the Stripe API from
applications written in the PHP language. It includes a pre-defined set of
Expand Down Expand Up @@ -249,7 +248,9 @@ New features and bug fixes are released on the latest major version of the Strip

## Development

Get [Composer][composer]. For example, on Mac OS:
We use [just](https://github.com/casey/just) for conveniently running development tasks. You can use them directly, or copy the commands out of the `justfile`. To our help docs, run `just`.

To get started, install [Composer][composer]. For example, on Mac OS:

```bash
brew install composer
Expand All @@ -258,7 +259,8 @@ brew install composer
Install dependencies:

```bash
composer install
just install
# or: composer install
```

The test suite depends on [stripe-mock], so make sure to fetch and run it from a
Expand All @@ -273,13 +275,15 @@ stripe-mock
Install dependencies as mentioned above (which will resolve [PHPUnit](http://packagist.org/packages/phpunit/phpunit)), then you can run the test suite:

```bash
./vendor/bin/phpunit
just test
# or: ./vendor/bin/phpunit
```

Or to run an individual test file:

```bash
./vendor/bin/phpunit tests/Stripe/UtilTest.php
just test tests/Stripe/UtilTest.php
# or: ./vendor/bin/phpunit tests/Stripe/UtilTest.php
```

Update bundled CA certificates from the [Mozilla cURL release][curl]:
Expand All @@ -291,7 +295,8 @@ Update bundled CA certificates from the [Mozilla cURL release][curl]:
The library uses [PHP CS Fixer][php-cs-fixer] for code formatting. Code must be formatted before PRs are submitted, otherwise CI will fail. Run the formatter with:

```bash
./vendor/bin/php-cs-fixer fix -v .
just format
# or: ./vendor/bin/php-cs-fixer fix -v .
```

## Attention plugin developers
Expand Down
65 changes: 65 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import? '../sdk-codegen/justfile'

set quiet

export PATH := "./vendor/bin:" + env_var('PATH')
PHPDOCUMENTOR_VERSION := "v3.0.0"

_default:
just --list --unsorted

# install vendored dependencies; only used locally
[group('useful')]
install:
composer install

[no-exit-message]
[group('useful')]
test *options:
phpunit {{ options }}

[group('CI')]
[confirm("This will modify local files and is intended for use in CI; do you want to proceed?")]
ci-test autoload:
echo "running build.php with argument: {{ autoload }}"
./build.php {{ autoload }}

[group('useful')]
format *options:
PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -v --using-cache=no {{ options }}

# for backwards compatibility; ideally removed later
[private]
alias codegen-format := format

[group('CI')]
format-check: (format "--dry-run")

[group('CI')]
lint *options:
php -d memory_limit=512M vendor/bin/phpstan analyse lib tests {{options}}

# for backwards compatibility; ideally removed later
[private]
alias phpstan := lint

[group('misc')]
phpstan-baseline: (lint "--generate-baseline")

# called by tooling
[private]
update-version version:
echo "{{ version }}" > VERSION
perl -pi -e 's|VERSION = '\''[.\-\w\d]+'\''|VERSION = '\''{{ version }}'\''|' lib/Stripe.php

[group('misc')]
phpdoc:
#!/usr/bin/env bash
set -euo pipefail

if [ ! -f vendor/bin/phpdoc ]; then
curl -sfL https://github.com/phpDocumentor/phpDocumentor/releases/download/{{ PHPDOCUMENTOR_VERSION }}/phpDocumentor.phar -o vendor/bin/phpdoc
chmod +x vendor/bin/phpdoc
fi

phpdoc
3 changes: 0 additions & 3 deletions phpunit.no_autoload.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@
<directory>lib</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="clover.xml"/>
</logging>
</phpunit>
3 changes: 0 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@
<directory>lib</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="clover.xml"/>
</logging>
</phpunit>
Loading