From 837638dafb5482a7baacde3ba2f02ebf52b0d5a6 Mon Sep 17 00:00:00 2001 From: Econa77 Date: Mon, 9 Oct 2023 22:17:06 +0900 Subject: [PATCH 1/3] Optimize GitHub Actions mint cache (#90) --- .github/workflows/Danger.yml | 56 +++++++++--------------------------- Dangerfile | 2 +- 2 files changed, 15 insertions(+), 43 deletions(-) diff --git a/.github/workflows/Danger.yml b/.github/workflows/Danger.yml index 343f035..56b57b2 100644 --- a/.github/workflows/Danger.yml +++ b/.github/workflows/Danger.yml @@ -1,67 +1,39 @@ name: Danger - -on: pull_request - +on: + pull_request: + push: + branches: + - master jobs: danger: - runs-on: macos-13 - steps: - uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 - - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: '3.2' - - - name: Select Xcode - run: sudo xcode-select -s /Applications/Xcode_15.0.app/Contents/Developer - - - name: Cache RubyGems - uses: actions/cache@v1 + bundler-cache: true + - name: Cache Mint + uses: actions/cache@v3 with: - path: vendor/bundle - key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} + path: .mint + key: ${{ runner.os }}-mint-${{ env.SWIFTLINT_VERSION }} restore-keys: | - ${{ runner.os }}-gem- - - - name: Cache Mint Builds - uses: actions/cache@v1 - with: - path: ${{ env.MINT_PATH }} - key: ${{ runner.os }}-mint-build-${{ env.SWIFTLINT_VERSION }} - restore-keys: | - ${{ runner.os }}-mint-build- - - - name: Cache Mint Links - uses: actions/cache@v1 - with: - path: ${{ env.MINT_LINK_PATH }} - key: ${{ runner.os }}-mint-link-${{ env.SWIFTLINT_VERSION }} - restore-keys: | - ${{ runner.os }}-mint-link- - - - name: Bundle install - run: | - gem install bundler - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 - + ${{ runner.os }}-mint- - name: Install Mint and Packages run: | brew install mint mint install realm/SwiftLint@${{ env.SWIFTLINT_VERSION }} - - name: Run Danger run: bundle exec danger env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - env: - MINT_PATH: ${{ github.workspace }}/mint - MINT_LINK_PATH: ${{ github.workspace }}/mint/bin + MINT_PATH: .mint/lib + MINT_LINK_PATH: .mint/bin SWIFTLINT_VERSION: 0.53.0 + DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer diff --git a/Dangerfile b/Dangerfile index cf6f963..7371937 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,4 +1,4 @@ github.dismiss_out_of_range_messages swiftlint.config_file = '.swiftlint.yml' -swiftlint.binary_path = './mint/bin/swiftlint' +swiftlint.binary_path = '.mint/bin/swiftlint' swiftlint.lint_files(inline_mode: true) From 52a9879348401a6773c9eb2359c4c67f68e59743 Mon Sep 17 00:00:00 2001 From: Econa77 Date: Mon, 9 Oct 2023 22:34:56 +0900 Subject: [PATCH 2/3] Add permissions for running Danger (#91) --- .github/workflows/Danger.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/Danger.yml b/.github/workflows/Danger.yml index 56b57b2..52346a9 100644 --- a/.github/workflows/Danger.yml +++ b/.github/workflows/Danger.yml @@ -4,6 +4,8 @@ on: push: branches: - master +permissions: + pull-requests: write jobs: danger: runs-on: macos-13 From 87babf2fae514034a510bc56293863249da8da94 Mon Sep 17 00:00:00 2001 From: Econa77 Date: Wed, 11 Oct 2023 03:48:24 +0900 Subject: [PATCH 3/3] Disable Danger in cases where permissions cannot be passed to GITHUB_TOKEN (#92) --- .github/workflows/Danger.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Danger.yml b/.github/workflows/Danger.yml index 52346a9..ed8517c 100644 --- a/.github/workflows/Danger.yml +++ b/.github/workflows/Danger.yml @@ -4,11 +4,11 @@ on: push: branches: - master -permissions: - pull-requests: write jobs: danger: runs-on: macos-13 + # https://github.com/danger/danger/issues/1103 + if: (github.event.pull_request.head.repo.fork == false) steps: - uses: actions/checkout@v4 with: