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

fix: Improve composer.lock behavior with ignore-cache #260

Open
wants to merge 5 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ When you do begin working on your feature, here are some guidelines to consider:
* **Submit one feature per pull request.** If you have multiple features you
wish to submit, please break them into separate pull requests.
* **Write good commit messages.** This project follows the
[Conventional Commits][] specification and uses Git hooks to ensure all
[Conventional Commits][conv-commit] specification and uses Git hooks to ensure all
commits follow this standard. Running `composer install` will set up the Git
hooks, so when you run `git commit`, you'll be prompted to create a commit
using the Conventional Commits rules.
Expand Down Expand Up @@ -126,3 +126,4 @@ Your new test should run along with the other tests.
[issues]: https://github.com/ramsey/composer-install/issues
[pull requests]: https://github.com/ramsey/composer-install/pulls
[gh-flow]: https://guides.github.com/introduction/flow/
[conv-commit]: https://www.conventionalcommits.org/
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ For example:

#### ignore-cache

Normally, ramsey/composer-install preserves composer's cache between jobs
so that subsequent identically-invoked jobs execute faster.
If you have jobs for which you wish to completely ignore the caching step, you
may use the `ignore-cache` input parameter. When present, ramsey/composer-install
will neither read from nor write to the cache.
Expand Down Expand Up @@ -174,6 +176,17 @@ even more specific, you can specify a suffix to be added to the cache key via th

:warning: Note: specifying a `custom-cache-key` will take precedence over the `custom-cache-suffix`.


#### require-lock-file

By default, if no composer.lock file is found in the working directory
ramsey/composer-install will invoke `composer update` regardless of the value of
`dependency-versions`.

If this is set to a value of `true`, ramsey/composer-install will fail in its
execution if it does not find a lock file.


### Fork and private repositories

Sometimes it's needed to use the `repositories` key in your `composer.json` to pull in forks, PRs with patches or private repositories. In this case, your GitHub Action may start failing with a `Could not authenticate against github.com` error message. To solve this, you need to add a GitHub Personal Access token, and this bit to your Action configuration:
Expand Down
1 change: 0 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ runs:

- name: "Determine Composer paths"
id: "composer"
if: steps.should-cache.outputs.do-cache == 1
shell: "bash"
run: |
${GITHUB_ACTION_PATH}/bin/composer_paths.sh \
Expand Down
2 changes: 1 addition & 1 deletion bin/composer_paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if [ ! -f "${composer_lock}" ]; then
composer_lock=""
fi

composer_version="$($composer_path --version)"
composer_version="$($composer_path --version 2>/dev/null)"
cache_dir="$($composer_path --working-dir="${working_directory}" config cache-dir)"

echo "::debug::Composer path is '${composer_path}'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_01.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "" "" "" "" "" "composer.lock"
spawn ../../bin/composer_install.sh "" "" "" "" "" "composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer install --no-interaction --no-progress --ansi'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_02.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "lowest" "" "" "" "" "composer.lock"
spawn ../../bin/composer_install.sh "lowest" "" "" "" "" "composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer update --no-interaction --no-progress --ansi --prefer-lowest --prefer-stable'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_03.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "highest" "" "" "" "" "composer.lock"
spawn ../../bin/composer_install.sh "highest" "" "" "" "" "composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer update --no-interaction --no-progress --ansi'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_04.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "locked" "" "" "" "" "composer.lock"
spawn ../../bin/composer_install.sh "locked" "" "" "" "" "composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer install --no-interaction --no-progress --ansi'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_05.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "" "--ignore-platform-reqs --optimize-autoloader" "" "" "" "composer.lock"
spawn ../../bin/composer_install.sh "" "--ignore-platform-reqs --optimize-autoloader" "" "" "" "composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer install --no-interaction --no-progress --ansi --ignore-platform-reqs --optimize-autoloader'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_06.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "lowest" "--ignore-platform-reqs --optimize-autoloader" "" "" "" "composer.lock"
spawn ../../bin/composer_install.sh "lowest" "--ignore-platform-reqs --optimize-autoloader" "" "" "" "composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer update --no-interaction --no-progress --ansi --prefer-lowest --prefer-stable --ignore-platform-reqs --optimize-autoloader'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_07.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "highest" "--ignore-platform-reqs --optimize-autoloader" "" "" "" "composer.lock"
spawn ../../bin/composer_install.sh "highest" "--ignore-platform-reqs --optimize-autoloader" "" "" "" "composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer update --no-interaction --no-progress --ansi --ignore-platform-reqs --optimize-autoloader'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_08.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "locked" "--ignore-platform-reqs --optimize-autoloader" "" "" "" "composer.lock"
spawn ../../bin/composer_install.sh "locked" "--ignore-platform-reqs --optimize-autoloader" "" "" "" "composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer install --no-interaction --no-progress --ansi --ignore-platform-reqs --optimize-autoloader'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_09.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "" "" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock"
spawn ../../bin/composer_install.sh "" "" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer install --no-interaction --no-progress --ansi --working-dir ../fixtures/with-lock-file'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_10.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "lowest" "" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock"
spawn ../../bin/composer_install.sh "lowest" "" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer update --no-interaction --no-progress --ansi --prefer-lowest --prefer-stable --working-dir ../fixtures/with-lock-file'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_11.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "highest" "" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock"
spawn ../../bin/composer_install.sh "highest" "" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer update --no-interaction --no-progress --ansi --working-dir ../fixtures/with-lock-file'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_12.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "locked" "" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock"
spawn ../../bin/composer_install.sh "locked" "" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer install --no-interaction --no-progress --ansi --working-dir ../fixtures/with-lock-file'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_13.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "" "--ignore-platform-reqs --optimize-autoloader" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock"
spawn ../../bin/composer_install.sh "" "--ignore-platform-reqs --optimize-autoloader" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer install --no-interaction --no-progress --ansi --ignore-platform-reqs --optimize-autoloader --working-dir ../fixtures/with-lock-file'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_14.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "lowest" "--ignore-platform-reqs --optimize-autoloader" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock"
spawn ../../bin/composer_install.sh "lowest" "--ignore-platform-reqs --optimize-autoloader" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer update --no-interaction --no-progress --ansi --prefer-lowest --prefer-stable --ignore-platform-reqs --optimize-autoloader --working-dir ../fixtures/with-lock-file'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_15.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "highest" "--ignore-platform-reqs --optimize-autoloader" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock"
spawn ../../bin/composer_install.sh "highest" "--ignore-platform-reqs --optimize-autoloader" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer update --no-interaction --no-progress --ansi --ignore-platform-reqs --optimize-autoloader --working-dir ../fixtures/with-lock-file'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_16.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "locked" "--ignore-platform-reqs --optimize-autoloader" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock"
spawn ../../bin/composer_install.sh "locked" "--ignore-platform-reqs --optimize-autoloader" "../fixtures/with-lock-file" "" "" "../fixtures/with-lock-file/composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer install --no-interaction --no-progress --ansi --ignore-platform-reqs --optimize-autoloader --working-dir ../fixtures/with-lock-file'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_17.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "foobar" "" "" "" "" "composer.lock"
spawn ../../bin/composer_install.sh "foobar" "" "" "" "" "composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer install --no-interaction --no-progress --ansi'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_18.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "" "" "" "" "../fixtures/composer.phar" "composer.lock"
spawn ../../bin/composer_install.sh "" "" "" "" "../fixtures/composer.phar" "composer.lock" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php ../fixtures/composer.phar install --no-interaction --no-progress --ansi'"
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer_install_19.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "" "" "../fixtures/no-lock-file" "" "" ""
spawn ../../bin/composer_install.sh "" "" "../fixtures/no-lock-file" "" "" "" ""
match_max 100000

expect "::debug::Using the following Composer command: '*/php */composer update --no-interaction --no-progress --ansi --working-dir ../fixtures/no-lock-file'"
Expand Down
8 changes: 8 additions & 0 deletions tests/expect/composer_install_20.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env -S expect -f

set timeout 3
spawn ../../bin/composer_install.sh "" "" "../fixtures/no-lock-file" "" "" "" "true"
match_max 100000

expect "::error title=Composer Lock File Not Found::Unable to find 'composer.lock'"
expect eof
Loading