From dc2f41cb8dd91c30ba05a23f9a34af1b06934900 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Sun, 4 Dec 2022 05:02:52 +0000 Subject: [PATCH] workflows: set working directory to repo location --- .github/workflows/docs.yml | 10 +++---- .github/workflows/sorbet.yml | 9 ++++--- .github/workflows/spdx.yml | 7 +++-- .../sponsors-maintainers-man-completions.yml | 27 ++++++++++--------- .github/workflows/tests.yml | 6 +++++ .github/workflows/vendor-gems.yml | 7 +++-- 6 files changed, 42 insertions(+), 24 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d679576185..88903a17a4 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,9 +13,6 @@ jobs: linting: if: github.repository == 'Homebrew/brew' runs-on: ubuntu-22.04 - defaults: - run: - working-directory: docs steps: - name: Set up Homebrew id: set-up-homebrew @@ -25,6 +22,7 @@ jobs: run: brew install vale - name: Run vale for docs linting + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}/docs run: vale . - name: Install Ruby @@ -32,12 +30,14 @@ jobs: with: ruby-version: "2.7" bundler-cache: true - working-directory: docs + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}/docs - name: Check Markdown syntax + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}/docs run: bundle exec rake lint - name: Build docs site + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}/docs run: bundle exec rake build rubydoc: @@ -63,5 +63,5 @@ jobs: bundler-cache: true - name: Process rubydoc comments - working-directory: Library/Homebrew + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}/Library/Homebrew run: bundle exec yard doc --plugin sorbet --no-output --fail-on-warning diff --git a/.github/workflows/sorbet.yml b/.github/workflows/sorbet.yml index ab46d81514..815aa04aad 100644 --- a/.github/workflows/sorbet.yml +++ b/.github/workflows/sorbet.yml @@ -37,6 +37,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }} + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} run: | git fetch origin @@ -46,15 +47,15 @@ jobs: if git ls-remote --exit-code --heads origin "${BRANCH}" then git checkout "${BRANCH}" - git checkout "${GITHUB_WORKSPACE}/Library/Homebrew/sorbet" + git checkout "Library/Homebrew/sorbet" else git checkout --no-track -B "${BRANCH}" origin/master fi brew typecheck --update - if ! git diff --stat --exit-code "${GITHUB_WORKSPACE}/Library/Homebrew/sorbet" + if ! git diff --stat --exit-code "Library/Homebrew/sorbet" then - git add "${GITHUB_WORKSPACE}/Library/Homebrew/sorbet" + git add "Library/Homebrew/sorbet" git commit -m "sorbet: Update RBI files." \ -m "Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow." echo "committed=true" >> $GITHUB_OUTPUT @@ -70,6 +71,7 @@ jobs: uses: Homebrew/actions/git-try-push@master with: token: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} + directory: ${{ steps.set-up-homebrew.outputs.repository-path }} branch: ${{ steps.update.outputs.branch }} force: true origin_branch: "master" @@ -79,3 +81,4 @@ jobs: run: hub pull-request --no-edit env: GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} diff --git a/.github/workflows/spdx.yml b/.github/workflows/spdx.yml index fbd2527a07..45c4abc42f 100644 --- a/.github/workflows/spdx.yml +++ b/.github/workflows/spdx.yml @@ -36,6 +36,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }} + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} run: | git fetch origin @@ -45,14 +46,14 @@ jobs: if git ls-remote --exit-code --heads origin "${BRANCH}" then git checkout "${BRANCH}" - git checkout "${GITHUB_WORKSPACE}/Library/Homebrew/data/spdx" + git checkout "Library/Homebrew/data/spdx" else git checkout --no-track -B "${BRANCH}" origin/master fi if brew update-license-data then - git add "${GITHUB_WORKSPACE}/Library/Homebrew/data/spdx" + git add "Library/Homebrew/data/spdx" git commit -m "spdx: update license data." -m "Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/spdx.yml)." echo "committed=true" >> $GITHUB_OUTPUT PULL_REQUEST_STATE="$(gh pr view --json=state | jq -r ".state")" @@ -67,6 +68,7 @@ jobs: uses: Homebrew/actions/git-try-push@master with: token: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} + directory: ${{ steps.set-up-homebrew.outputs.repository-path }} branch: ${{ steps.update.outputs.branch }} force: true origin_branch: "master" @@ -76,3 +78,4 @@ jobs: run: hub pull-request --no-edit env: GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} diff --git a/.github/workflows/sponsors-maintainers-man-completions.yml b/.github/workflows/sponsors-maintainers-man-completions.yml index e46a555531..45850a82d7 100644 --- a/.github/workflows/sponsors-maintainers-man-completions.yml +++ b/.github/workflows/sponsors-maintainers-man-completions.yml @@ -61,17 +61,17 @@ jobs: if git ls-remote --exit-code --heads origin "${BRANCH}" then git checkout "${BRANCH}" - git checkout "${GITHUB_WORKSPACE}/README.md" \ - "${GITHUB_WORKSPACE}/docs/Manpage.md" \ - "${GITHUB_WORKSPACE}/manpages/brew.1" \ - "${GITHUB_WORKSPACE}/completions" + git checkout "README.md" \ + "docs/Manpage.md" \ + "manpages/brew.1" \ + "completions" else git checkout --no-track -B "${BRANCH}" origin/master fi if brew update-sponsors then - git add "${GITHUB_WORKSPACE}/README.md" + git add "README.md" git commit -m "Update sponsors." \ -m "Autogenerated by the [sponsors-maintainers-man-completions](https://github.com/Homebrew/brew/blob/HEAD/.github/workflows/sponsors-maintainers-man-completions.yml) workflow." COMMITTED=true @@ -79,9 +79,9 @@ jobs: if brew update-maintainers then - git add "${GITHUB_WORKSPACE}/README.md" \ - "${GITHUB_WORKSPACE}/docs/Manpage.md" \ - "${GITHUB_WORKSPACE}/manpages/brew.1" + git add "README.md" \ + "docs/Manpage.md" \ + "manpages/brew.1" git commit -m "Update maintainers." \ -m "Autogenerated by the [sponsors-maintainers-man-completions](https://github.com/Homebrew/brew/blob/HEAD/.github/workflows/sponsors-maintainers-man-completions.yml) workflow." COMMITTED=true @@ -89,10 +89,10 @@ jobs: if brew generate-man-completions then - git add "${GITHUB_WORKSPACE}/README.md" \ - "${GITHUB_WORKSPACE}/docs/Manpage.md" \ - "${GITHUB_WORKSPACE}/manpages/brew.1" \ - "${GITHUB_WORKSPACE}/completions" + git add "README.md" \ + "docs/Manpage.md" \ + "manpages/brew.1" \ + "completions" git commit -m "Update manpage and completions." \ -m "Autogenerated by the [sponsors-maintainers-man-completions](https://github.com/Homebrew/brew/blob/HEAD/.github/workflows/sponsors-maintainers-man-completions.yml) workflow." COMMITTED=true @@ -111,12 +111,14 @@ jobs: GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_BREW_UPDATE_SPONSORS_MAINTAINERS_TOKEN }} HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }} + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} - name: Push commits if: steps.update.outputs.committed == 'true' uses: Homebrew/actions/git-try-push@master with: token: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} + directory: ${{ steps.set-up-homebrew.outputs.repository-path }} branch: ${{ steps.update.outputs.branch }} force: true origin_branch: "master" @@ -126,3 +128,4 @@ jobs: run: hub pull-request --no-edit env: GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b9733f466c..dd078df819 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -148,6 +148,7 @@ jobs: run: brew install-bundler-gems --groups=sorbet - name: Check for uncommitted RubyGems + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} run: git diff --stat --exit-code Library/Homebrew/vendor/bundle/ruby docker: @@ -159,6 +160,7 @@ jobs: uses: Homebrew/actions/setup-homebrew@master - name: Build Docker image + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} run: | docker build -t brew --build-arg=version=22.04 \ --label org.opencontainers.image.created="$(date --rfc-3339=seconds --utc)" \ @@ -183,6 +185,7 @@ jobs: docker push "homebrew/ubuntu22.04:master" - name: Build deprecated 16.04 Docker image + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} run: | echo "homebrew/ubuntu16.04:master is deprecated and will soon be retired. Use homebrew/ubuntu22.04:master or homebrew/ubuntu16.04 or homebrew/brew. For CI, homebrew/ubuntu22.04:master is recommended." > .docker-deprecate docker build -t brew-deprecated --build-arg=version=16.04 \ @@ -262,6 +265,7 @@ jobs: - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 with: + directory: ${{ steps.set-up-homebrew.outputs.repository-path }} files: Library/Homebrew/test/coverage/coverage.xml test-default-formula-linux: @@ -310,6 +314,7 @@ jobs: run: brew install-bundler-gems --groups=sorbet - name: Check for uncommitted RubyGems + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} run: git diff --stat --exit-code Library/Homebrew/vendor/bundle/ruby - run: brew doctor @@ -373,4 +378,5 @@ jobs: - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 with: + directory: ${{ steps.set-up-homebrew.outputs.repository-path }} files: Library/Homebrew/test/coverage/coverage.xml diff --git a/.github/workflows/vendor-gems.yml b/.github/workflows/vendor-gems.yml index 4a174205b9..1d54eb96f3 100644 --- a/.github/workflows/vendor-gems.yml +++ b/.github/workflows/vendor-gems.yml @@ -49,6 +49,7 @@ jobs: echo "gem_name=${gem_name}" >> $GITHUB_OUTPUT env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} - name: Vendor Gems env: @@ -59,11 +60,12 @@ jobs: env: GEM_NAME: ${{ steps.checkout.outputs.gem_name }} HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }} + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} run: | brew typecheck --update - if ! git diff --stat --exit-code "${GITHUB_WORKSPACE}/Library/Homebrew/sorbet" + if ! git diff --stat --exit-code "Library/Homebrew/sorbet" then - git add "${GITHUB_WORKSPACE}/Library/Homebrew/sorbet" + git add "Library/Homebrew/sorbet" git commit -m "Update RBI files for ${GEM_NAME}." \ -m "Autogenerated by the [vendor-gems](https://github.com/Homebrew/brew/blob/HEAD/.github/workflows/vendor-gems.yml) workflow." fi @@ -72,5 +74,6 @@ jobs: uses: Homebrew/actions/git-try-push@master with: token: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} + directory: ${{ steps.set-up-homebrew.outputs.repository-path }} branch: ${{ steps.checkout.outputs.branch }} force: true