-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add build, detect, and integration tests * Use 'composer check-platform-reqs' to generate an ini file for extensions * Use "os" instead of "io/ioutil" - https://pkg.go.dev/io/ioutil - "As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details." * Use "To(Succeed())" matcher instead of "NotTo(HaveOccurred())" * Update README for clarity * Add godocs and additional test coverage for PHP Version Resolver * Clarify how "check-platform-reqs" generates a PHP INI file * Add godoc * Add godocs * fix typo * Add additional logs and integration testing for those logs * Add additional test cases, especially for errors and logging * Use .NotTo(HaveOccurred()) matcher when appropriate * Increase failure cases or mark err handling as untested - Almost all of the err handling should only occurr if there's a problem with the layers directory * Set layer cache flag equal to layer build flag * Fix lint * Remove README TODOs Co-authored-by: Sophie Wigmore <[email protected]>
- Loading branch information
1 parent
a02b649
commit 29ec8c6
Showing
150 changed files
with
19,993 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Auto-Merge | ||
|
||
on: | ||
pull_request_review: | ||
types: | ||
- submitted | ||
|
||
jobs: | ||
automerge: | ||
name: Merge or Rebase | ||
if: ${{ github.event.review.user.login == 'paketo-bot-reviewer' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Fetch Pull Request Details | ||
id: pull_request | ||
env: | ||
NUMBER: ${{ github.event.pull_request.number }} | ||
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} | ||
run: | | ||
payload="$( | ||
curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${NUMBER}" \ | ||
--silent \ | ||
--location \ | ||
--header "Authorization: token ${GITHUB_TOKEN}" | ||
)" | ||
echo "::set-output name=mergeable_state::$(echo "${payload}" | jq -r -c .mergeable_state)" | ||
- name: Merge | ||
if: ${{ steps.pull_request.outputs.mergeable_state == 'clean' || steps.pull_request.outputs.mergeable_state == 'unstable' }} | ||
uses: paketo-buildpacks/github-config/actions/pull-request/merge@main | ||
with: | ||
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} | ||
number: ${{ github.event.pull_request.number }} | ||
|
||
- name: Rebase | ||
if: ${{ steps.pull_request.outputs.mergeable_state == 'behind' }} | ||
uses: paketo-buildpacks/github-config/actions/pull-request/rebase@main | ||
with: | ||
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} | ||
number: ${{ github.event.pull_request.number }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Validate PR Labels | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- synchronize | ||
- opened | ||
- reopened | ||
- labeled | ||
- unlabeled | ||
|
||
concurrency: pr_labels | ||
|
||
jobs: | ||
semver: | ||
name: Ensure Minimal Semver Labels | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: mheap/github-action-required-labels@v1 | ||
with: | ||
count: 1 | ||
labels: semver:major, semver:minor, semver:patch | ||
mode: exactly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea/ | ||
build/ | ||
.bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,141 @@ | ||
# Paketo Composer Install Buildpack | ||
# PHP Composer Install Cloud Native Buildpack | ||
|
||
This buildpack runs the [composer](https://getcomposer.org/) command `composer install` to download project dependencies. | ||
It requires both `composer` and `php` on the path (see [requires](#requires)). | ||
|
||
A usage example can be found in the | ||
[`samples` repository under the `php/composer` directory](https://github.com/paketo-buildpacks/samples/tree/main/php/composer). | ||
|
||
## Detection | ||
|
||
Will add these requires/provisions to the build plan if and only if a `composer.json` file is found. | ||
|
||
### Requires: | ||
|
||
- `composer` | ||
- `php` | ||
|
||
### Provides: | ||
|
||
- `composer-packages` | ||
|
||
## Build | ||
|
||
Will run `composer install` in the project workspace to download project dependencies. | ||
The dependencies will be placed in a new layer and symlinked into the workspace at the | ||
location specified by `COMPOSER_VENDOR_DIR`, which defaults to `vendor`. | ||
|
||
If dependencies are needed for Composer install scripts, use `BP_COMPOSER_INSTALL_GLOBAL` | ||
to specify which dependencies to install. | ||
|
||
Use of a `composer.lock` file will enable caching of the downloaded dependencies, such that | ||
subsequent builds with the same `composer.lock` file will not need to run `composer install` again. | ||
|
||
## Integration | ||
|
||
The PHP Composer CNB provides `composer-packages` as a dependency. Downstream buildpacks | ||
can require that dependency by generating a [Build Plan | ||
TOML](https://github.com/buildpacks/spec/blob/master/buildpack.md#build-plan-toml) | ||
file that looks like the following: | ||
|
||
```toml | ||
[[requires]] | ||
|
||
# The PHP Composer Install provision is named `composer-packages`. | ||
# This value is considered part of the public API for the buildpack and will not | ||
# change without a plan for deprecation. | ||
name = "composer-packages" | ||
|
||
# The PHP Composer Install buildpack requires some additional metadata options. | ||
# If neither metadata.build or metadata.launch is provided, this buidpack will contribute | ||
# an ignored layer | ||
[requires.metadata] | ||
|
||
# Setting the build flag to true will ensure that packages installed by running | ||
# `composer install` are available for subsequent buildpacks during their launch phase | ||
launch = true | ||
|
||
# Setting the build flag to true will ensure that packages installed by running | ||
# `composer install` are available for subsequent buildpacks during their build phase | ||
build = true | ||
``` | ||
## Logging Configurations | ||
|
||
To configure the level of log output from the **buildpack itself**, set the | ||
`BP_LOG_LEVEL` environment variable at build time either directly or through | ||
a [`project.toml` file](https://github.com/buildpacks/spec/blob/main/extensions/project-descriptor.md) | ||
If no value is set, the default value of `INFO` will be used. | ||
|
||
The options for this setting are: | ||
- `INFO`: (Default) log information about the detection and build processes | ||
- `DEBUG`: log debugging information about the detection and build processes | ||
|
||
```shell | ||
pack build my-app --env BP_LOG_LEVEL=DEBUG | ||
``` | ||
|
||
## Usage | ||
|
||
To package this buildpack for consumption | ||
|
||
``` | ||
$ ./scripts/package.sh -v <version> | ||
``` | ||
|
||
This builds the buildpack's Go source using `GOOS=linux` by default. You can supply another value as the first argument to package.sh. | ||
|
||
## Configuration | ||
|
||
### `COMPOSER` | ||
|
||
The `COMPOSER` variable allows you to specify the filename of `composer.json`. | ||
When set, this buildpack will use this location instead of `composer.json` in the detection phase. | ||
This value must be relative to the project root. | ||
|
||
For more information, please reference the [composer docs](https://getcomposer.org/doc/03-cli.md#composer). | ||
|
||
```shell | ||
COMPOSER=somewhere/composer-other.json | ||
``` | ||
|
||
### `BP_COMPOSER_INSTALL_OPTIONS` | ||
|
||
Use `BP_COMPOSER_INSTALL_OPTIONS` to specify options for the Composer [install command](https://getcomposer.org/doc/03-cli.md#install-i). | ||
This buildpacks will always prepend `--no-progress` to the list of install options. | ||
The default is `--no-dev`. | ||
|
||
Note: `BP_COMPOSER_INSTALL_OPTIONS` will be parsed using the [shellwords library](https://github.com/mattn/go-shellwords). | ||
|
||
```shell | ||
# Note that env variables will typically be provided to this buildpack using `pack build -e` | ||
BP_COMPOSER_INSTALL_OPTIONS=--prefer-install --ignore-platform-reqs | ||
# will result in an installation command of `composer install --no-progress --prefer-install --ignore-platform-reqs` | ||
BP_COMPOSER_INSTALL_OPTIONS= # Note that this is set to empty | ||
# will result in an installation command of `composer install --no-progress` | ||
unset BP_COMPOSER_INSTALL_OPTIONS | ||
# will result in an installation command of `composer install --no-progress --no-dev` | ||
``` | ||
|
||
### `BP_COMPOSER_INSTALL_GLOBAL` | ||
|
||
Use `BP_COMPOSER_INSTALL_GLOBAL` to specify packages required by Composer scripts. | ||
These will be installed using `composer global require`. | ||
These packages will not be available to the application. | ||
|
||
```shell | ||
BP_COMPOSER_INSTALL_GLOBAL="friendsofphp/php-cs-fixer squizlabs/php_codesniffer=*" | ||
``` | ||
|
||
### Other environment variables | ||
|
||
Other environment variables used by Composer may be passed in to configure Composer behavior. | ||
See the [full list here](https://getcomposer.org/doc/03-cli.md#environment-variables). | ||
A few examples are shown here. | ||
|
||
- `COMPOSER_VENDOR_DIR`: | ||
Used to make Composer install the dependencies into a directory other than `vendor`. | ||
This value must be underneath the project root. | ||
|
||
- `COMPOSER_AUTH`: | ||
Used to set up authentication, for example to add a GitHub OAuth token to increase the | ||
default rate limit. |
Oops, something went wrong.