workflows: cleanup/fix tapioca and spdx update.

This commit is contained in:
Mike McQuaid 2020-08-21 15:34:57 +01:00
parent 3b71e3d4fd
commit 1d3adda693
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
6 changed files with 89 additions and 81 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 }}

View File

@ -1,57 +0,0 @@
name: Tapioca Update
on:
push:
paths:
- .github/workflows/tapioca-update.yml
schedule:
- cron: '0 0 */3 * *' # every three days
env:
HOMEBREW_SORBET: 1
jobs:
update-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
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.3
- name: Update Tapioca Definitions
run: |
cd "$GITHUB_WORKSPACE/Library/Homebrew"
bundle install
bundle exec tapioca sync --exclude json
bundle exec srb rbi hidden-definitions
if ! git diff --exit-code -- sorbet; then
BRANCH="tapioca-update"
if ! git ls-remote --exit-code --heads origin "$BRANCH"; then
git checkout -b "$BRANCH"
git commit -am "sorbet: Update gem RBI files using Tapioca
Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/actions?query=workflow%3A%22Tapioca+Update%22)."
fi
fi
- name: Push commits
uses: Homebrew/actions/git-try-push@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: tapioca-update
directory: Library/Homebrew/
- name: Open a PR
env:
GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
run: |
cd "$GITHUB_WORKSPACE/Library/Homebrew"
hub pull-request -m "$(git log -1 --format='%s%n%n%b')"

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\.
. .