diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 94ddb64..b53eed0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. @@ -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/ \ No newline at end of file diff --git a/README.md b/README.md index c50fe8e..4552fe6 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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: diff --git a/action.yml b/action.yml index 17339c4..35d8693 100644 --- a/action.yml +++ b/action.yml @@ -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 \ diff --git a/bin/composer_paths.sh b/bin/composer_paths.sh index decf725..f608e09 100755 --- a/bin/composer_paths.sh +++ b/bin/composer_paths.sh @@ -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}'" diff --git a/tests/expect/composer_install_01.exp b/tests/expect/composer_install_01.exp index cebb2d8..e84a76e 100755 --- a/tests/expect/composer_install_01.exp +++ b/tests/expect/composer_install_01.exp @@ -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'" diff --git a/tests/expect/composer_install_02.exp b/tests/expect/composer_install_02.exp index 9fc8bd9..01043ff 100755 --- a/tests/expect/composer_install_02.exp +++ b/tests/expect/composer_install_02.exp @@ -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'" diff --git a/tests/expect/composer_install_03.exp b/tests/expect/composer_install_03.exp index 91c5469..d035fad 100755 --- a/tests/expect/composer_install_03.exp +++ b/tests/expect/composer_install_03.exp @@ -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'" diff --git a/tests/expect/composer_install_04.exp b/tests/expect/composer_install_04.exp index af9fa20..1fbbee0 100755 --- a/tests/expect/composer_install_04.exp +++ b/tests/expect/composer_install_04.exp @@ -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'" diff --git a/tests/expect/composer_install_05.exp b/tests/expect/composer_install_05.exp index b2732dc..f44135b 100755 --- a/tests/expect/composer_install_05.exp +++ b/tests/expect/composer_install_05.exp @@ -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'" diff --git a/tests/expect/composer_install_06.exp b/tests/expect/composer_install_06.exp index c9e45ed..0738951 100755 --- a/tests/expect/composer_install_06.exp +++ b/tests/expect/composer_install_06.exp @@ -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'" diff --git a/tests/expect/composer_install_07.exp b/tests/expect/composer_install_07.exp index ca2b5b6..5eccc1f 100755 --- a/tests/expect/composer_install_07.exp +++ b/tests/expect/composer_install_07.exp @@ -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'" diff --git a/tests/expect/composer_install_08.exp b/tests/expect/composer_install_08.exp index 2678767..e0dd379 100755 --- a/tests/expect/composer_install_08.exp +++ b/tests/expect/composer_install_08.exp @@ -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'" diff --git a/tests/expect/composer_install_09.exp b/tests/expect/composer_install_09.exp index 4d030f7..6179993 100755 --- a/tests/expect/composer_install_09.exp +++ b/tests/expect/composer_install_09.exp @@ -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'" diff --git a/tests/expect/composer_install_10.exp b/tests/expect/composer_install_10.exp index 20324af..3e94314 100755 --- a/tests/expect/composer_install_10.exp +++ b/tests/expect/composer_install_10.exp @@ -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'" diff --git a/tests/expect/composer_install_11.exp b/tests/expect/composer_install_11.exp index 5db0e60..0e1614a 100755 --- a/tests/expect/composer_install_11.exp +++ b/tests/expect/composer_install_11.exp @@ -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'" diff --git a/tests/expect/composer_install_12.exp b/tests/expect/composer_install_12.exp index 35763ec..d7190e7 100755 --- a/tests/expect/composer_install_12.exp +++ b/tests/expect/composer_install_12.exp @@ -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'" diff --git a/tests/expect/composer_install_13.exp b/tests/expect/composer_install_13.exp index a6f84c4..925ba1a 100755 --- a/tests/expect/composer_install_13.exp +++ b/tests/expect/composer_install_13.exp @@ -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'" diff --git a/tests/expect/composer_install_14.exp b/tests/expect/composer_install_14.exp index 9fa7d07..bb54ba8 100755 --- a/tests/expect/composer_install_14.exp +++ b/tests/expect/composer_install_14.exp @@ -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'" diff --git a/tests/expect/composer_install_15.exp b/tests/expect/composer_install_15.exp index af1c715..801cc87 100755 --- a/tests/expect/composer_install_15.exp +++ b/tests/expect/composer_install_15.exp @@ -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'" diff --git a/tests/expect/composer_install_16.exp b/tests/expect/composer_install_16.exp index f2bb343..0a7b11c 100755 --- a/tests/expect/composer_install_16.exp +++ b/tests/expect/composer_install_16.exp @@ -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'" diff --git a/tests/expect/composer_install_17.exp b/tests/expect/composer_install_17.exp index 93cf0bf..fdd2b19 100755 --- a/tests/expect/composer_install_17.exp +++ b/tests/expect/composer_install_17.exp @@ -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'" diff --git a/tests/expect/composer_install_18.exp b/tests/expect/composer_install_18.exp index 77a0440..c6e7af1 100755 --- a/tests/expect/composer_install_18.exp +++ b/tests/expect/composer_install_18.exp @@ -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'" diff --git a/tests/expect/composer_install_19.exp b/tests/expect/composer_install_19.exp index 398c24e..feca718 100755 --- a/tests/expect/composer_install_19.exp +++ b/tests/expect/composer_install_19.exp @@ -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'" diff --git a/tests/expect/composer_install_20.exp b/tests/expect/composer_install_20.exp new file mode 100755 index 0000000..2edc2da --- /dev/null +++ b/tests/expect/composer_install_20.exp @@ -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 \ No newline at end of file