Skip to content

Commit 6ba32f2

Browse files
authored
GH Actions: various tweaks (#217)
* GH Actions: allow for manually triggering a workflow Triggering a workflow for a branch manually is not supported by default in GH Actions, but has to be explicitly allowed. This is useful if, for instance, an external action script or composer dependency has broken. Once a fix is available, failing builds for open PRs can be retriggered manually instead of having to be re-pushed to retrigger the workflow. Ref: https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/ * GH Actions: auto-cancel previous builds for same branch Previously, in Travis, when the same branch was pushed again and the "Auto cancellation" option on the "Settings" page had been turned on (as it was for most repos), any still running builds for the same branch would be stopped in favour of starting the build for the newly pushed version of the branch. To enable this behaviour in GH Actions, a `concurrency` configuration needs to be added to each workflow for which this should applied to. More than anything, this is a way to be kind to GitHub by not wasting resources which they so kindly provide to us for free. Refs: * https://github.blog/changelog/2021-04-19-github-actions-limit-workflow-run-or-job-concurrency/ * https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency * GH Actions: change job order The code coverage job is running the same command as the Expect tests. I'd like to suggest to only run code coverage when the Expect tests actually pass. To that end, I'm suggesting to reverse the order of the jobs in the workflow (`test` first, `code-coverage` second) and make the `code-coverage` job dependent on the `test` run (via `needs`), so it only runs when the tests pass. * GH Actions: don't run code coverage on forks Oftentimes, the "owner" of a fork won't have permission to upload code coverage data for the "main" repo and it would be very rare for them to have a CodeCov account setup linked to their fork, so a code coverage run can be limited to the "main" repo only. * GH Actions: version update for `codecov/codecov-action` A while back the `codecov/codecov-action` released a new major. As per the release notes: > On February 1, 2022, the v1 uploader will be full sunset and no longer function. This is due to the deprecation of the underlying bash uploader. This version uses the new uploader. Considering Feb 2022 is creeping closer every day, updating seems prudent. > Multiple fields have not been transferred from the bash uploader or have been deprecated. Notably many of the `functionalities` and `gcov_` arguments have been removed. This repo does not seem to be affected by this. Refs: * https://github.com/codecov/codecov-action/releases/tag/v2.0.0 * https://github.com/codecov/codecov-action/releases/tag/v2.0.1 * https://github.com/codecov/codecov-action/releases/tag/v2.0.2 * https://github.com/codecov/codecov-action/releases/tag/v2.0.3 * https://github.com/codecov/codecov-action/releases/tag/v2.1.0 * GH Actions: only run the action tests when the "expect" tests pass ... to be kind to GitHub for the resources they so freely provide, as when the `expect` tests fail, a commit/PR isn't ready for merge yet anyway. * GH Actions: add a job to run Composer normalize * GH Actions: use `ruby/setup-ruby` The `actions/setup-ruby` action has been archieved and is no longer maintained. Per the note in the README: > Please note: This action is deprecated and should no longer be used. The team at GitHub has ceased making and accepting code contributions or maintaining issues tracker. Please, migrate your workflows to the ruby/setup-ruby, which is being actively maintained by the official Ruby organization. This switches the workflow over to the `ruby/setup-ruby` action. Ref: https://github.com/ruby/setup-ruby Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
1 parent 6e86502 commit 6ba32f2

1 file changed

Lines changed: 46 additions & 22 deletions

File tree

.github/workflows/continuous-integration.yml

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,29 @@
22

33
name: "build"
44

5-
on: ["pull_request", "push"]
5+
on: ["pull_request", "push", "workflow_dispatch"]
6+
7+
# Cancels all previous workflow runs for the same branch that have not yet completed.
8+
concurrency:
9+
# The concurrency group contains the workflow name and the branch name.
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
612

713
jobs:
8-
code-coverage:
9-
name: "Code coverage"
14+
composer:
15+
name: "Check Composer"
1016
runs-on: "ubuntu-latest"
1117
steps:
1218
- name: "Checkout repository"
1319
uses: "actions/checkout@v2"
14-
- name: "Install expect"
15-
run: |
16-
sudo apt-get update
17-
sudo apt-get -y install expect
18-
- name: "Set up Ruby"
19-
uses: "actions/setup-ruby@v1"
20-
with:
21-
ruby-version: "2.7"
22-
- name: "Install Ruby dependencies"
23-
run: |
24-
gem install bashcov
25-
gem install codecov
2620
- name: "Set up PHP"
2721
uses: "shivammathur/setup-php@v2"
2822
with:
29-
php-version: "latest"
30-
tools: "composer:v2"
31-
coverage: "none"
32-
- name: "Run expect tests"
33-
run: "bashcov --root ./bin -- ./tests/bash-test.sh tests/tests.sh"
34-
- name: "Publish coverage report to Codecov"
35-
uses: "codecov/codecov-action@v1"
23+
php-version: 7.4
24+
tools: composer-normalize
25+
coverage: none
26+
- name: "Run Composer normalize"
27+
run: "composer-normalize --dry-run"
3628

3729
test:
3830
name: "Expect tests"
@@ -58,7 +50,39 @@ jobs:
5850
- name: "Run expect tests"
5951
run: "composer test"
6052

53+
code-coverage:
54+
needs: test
55+
if: github.repository == 'ramsey/composer-install'
56+
name: "Code coverage"
57+
runs-on: "ubuntu-latest"
58+
steps:
59+
- name: "Checkout repository"
60+
uses: "actions/checkout@v2"
61+
- name: "Install expect"
62+
run: |
63+
sudo apt-get update
64+
sudo apt-get -y install expect
65+
- name: "Set up Ruby"
66+
uses: "ruby/setup-ruby@v1"
67+
with:
68+
ruby-version: "2.7"
69+
- name: "Install Ruby dependencies"
70+
run: |
71+
gem install bashcov
72+
gem install codecov
73+
- name: "Set up PHP"
74+
uses: "shivammathur/setup-php@v2"
75+
with:
76+
php-version: "latest"
77+
tools: "composer:v2"
78+
coverage: "none"
79+
- name: "Run expect tests"
80+
run: "bashcov --root ./bin -- ./tests/bash-test.sh tests/tests.sh"
81+
- name: "Publish coverage report to Codecov"
82+
uses: "codecov/codecov-action@v2"
83+
6184
run:
85+
needs: test
6286
name: "Run action"
6387
runs-on: "${{ matrix.operating-system }}"
6488
strategy:

0 commit comments

Comments
 (0)