Merge pull request #8283 from Homebrew/test-automate-tapioca-update

.github/workflows: add action to update tapioca definitions
This commit is contained in:
Mike McQuaid 2020-08-21 16:34:17 +01:00 committed by GitHub
commit 755be7a32e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 89 additions and 24 deletions

View File

@ -1,4 +1,4 @@
name: Update license data name: Update SPDX license data
on: on:
push: push:
paths: paths:
@ -19,17 +19,33 @@ jobs:
with: with:
username: BrewTestBot username: BrewTestBot
- name: Update license data - name: Update SPDX license data
id: update
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
cd "$GITHUB_WORKSPACE/Library/Homebrew" cd "$GITHUB_WORKSPACE/Library/Homebrew"
if brew update-license-data --commit --fail-if-not-changed; then
SPDX_VERSION=$(jq -er .licenseListVersion data/spdx/spdx_licenses.json) if brew update-license-data --fail-if-not-changed; then
if ! git ls-remote --exit-code --heads origin "spdx-$SPDX_VERSION"; then if ! git ls-remote --exit-code --heads origin spdx-update; then
git checkout -b "spdx-$SPDX_VERSION" git checkout -B spdx-update
git push origin "spdx-$SPDX_VERSION" git commit -am "spdx: update license data." -m "Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/spdx.yml)."
hub pull-request -m "$(git log -1 --format='%s')" echo "::set-output name=committed::true"
fi fi
fi fi
- name: Push commits
if: steps.update.outputs.committed == 'true'
uses: Homebrew/actions/git-try-push@master
with:
token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
branch: spdx-update
- name: Open a pull request
if: steps.update.outputs.committed == 'true'
run: |
cd "$GITHUB_WORKSPACE/Library/Homebrew"
hub pull-request --no-edit
env:
GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}

63
.github/workflows/tapioca.yml vendored Normal file
View File

@ -0,0 +1,63 @@
name: Update Tapioca definitions
on:
push:
paths:
- .github/workflows/tapioca.yml
schedule:
- cron: '0 */12 * * *'
jobs:
tapioca:
if: github.repository == 'Homebrew/brew'
runs-on: ubuntu-latest
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Configure Git user
uses: Homebrew/actions/git-user-config@master
with:
username: BrewTestBot
# TODO: remove with `brew typecheck`
- name: Set up Ruby
uses: actions/setup-ruby@main
with:
ruby-version: '2.6'
- name: Install RubyGems
run: |
cd "$GITHUB_WORKSPACE/Library/Homebrew"
gem install bundler -v "~>1"
bundle install --jobs 4 --retry 3
- name: Update Tapioca definitions
id: update
run: |
cd "$GITHUB_WORKSPACE/Library/Homebrew"
# TODO: replace with `brew typecheck`
bundle exec tapioca sync --exclude json
bundle exec srb rbi hidden-definitions
git checkout -B tapioca-update
if ! git diff --exit-code -- sorbet; then
if ! git ls-remote --exit-code --heads origin tapioca-update; then
git commit -am "sorbet: update RBI files using Tapioca." -m "Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/tapioca.yml)."
echo "::set-output name=committed::true"
fi
fi
- name: Push commits
if: steps.update.outputs.committed == 'true'
uses: Homebrew/actions/git-try-push@master
with:
token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
branch: tapioca-update
- name: Open a pull request
if: steps.update.outputs.committed == 'true'
run: |
cd "$GITHUB_WORKSPACE/Library/Homebrew"
hub pull-request --no-edit
env:
GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}

View File

@ -16,8 +16,6 @@ module Homebrew
switch "--fail-if-not-changed", switch "--fail-if-not-changed",
description: "Return a failing status code if current license data's version is the same as " \ description: "Return a failing status code if current license data's version is the same as " \
"the upstream. This can be used to notify CI when the SPDX license data is out of date." "the upstream. This can be used to notify CI when the SPDX license data is out of date."
switch "--commit",
description: "Commit changes to the SPDX license data."
max_named 0 max_named 0
end end
end end
@ -27,14 +25,8 @@ module Homebrew
ohai "Updating SPDX license data..." ohai "Updating SPDX license data..."
SPDX.download_latest_license_data! SPDX.download_latest_license_data!
return unless args.fail_if_not_changed?
Homebrew.failed = system("git", "diff", "--stat", "--exit-code", SPDX::DATA_PATH) if args.fail_if_not_changed? Homebrew.failed = system("git", "diff", "--stat", "--exit-code", SPDX::DATA_PATH)
return unless args.commit?
ohai "git add"
safe_system "git", "add", SPDX::DATA_PATH
ohai "git commit"
system "git", "commit", "--message", "spdx license data: update to #{SPDX.latest_tag}"
end end
end end

View File

@ -1198,8 +1198,6 @@ working directory.
* `--fail-if-not-changed`: * `--fail-if-not-changed`:
Return a failing status code if current license data's version is the same as the upstream. This can be used to notify CI when the SPDX license data is out of date. Return a failing status code if current license data's version is the same as the upstream. This can be used to notify CI when the SPDX license data is out of date.
* `--commit`:
Commit changes to the SPDX license data.
### `update-python-resources` [*`options`*] *`formula`* ### `update-python-resources` [*`options`*] *`formula`*

View File

@ -1636,10 +1636,6 @@ Update SPDX license data in the Homebrew repository\.
\fB\-\-fail\-if\-not\-changed\fR \fB\-\-fail\-if\-not\-changed\fR
Return a failing status code if current license data\'s version is the same as the upstream\. This can be used to notify CI when the SPDX license data is out of date\. Return a failing status code if current license data\'s version is the same as the upstream\. This can be used to notify CI when the SPDX license data is out of date\.
. .
.TP
\fB\-\-commit\fR
Commit changes to the SPDX license data\.
.
.SS "\fBupdate\-python\-resources\fR [\fIoptions\fR] \fIformula\fR" .SS "\fBupdate\-python\-resources\fR [\fIoptions\fR] \fIformula\fR"
Update versions for PyPI resource blocks in \fIformula\fR\. Update versions for PyPI resource blocks in \fIformula\fR\.
. .