Skip to content

Commit 43431ba

Browse files
author
Alexey Alter-Pesotskiy
authored
[CIS-1830] Speed up bootstrap action (#62)
1 parent ff327d2 commit 43431ba

File tree

5 files changed

+41
-68
lines changed

5 files changed

+41
-68
lines changed

.github/actions/bootstrap/action.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,19 @@ description: 'Run bootstrap.sh'
33
runs:
44
using: "composite"
55
steps:
6-
- run: ./bootstrap.sh
7-
shell: bash
6+
- name: Cache RubyGems
7+
uses: actions/cache@v2
8+
id: rubygem-cache
9+
with:
10+
path: vendor/bundle
11+
key: ${{ runner.os }}-${{ env.ImageVersion }}-gem-${{ hashFiles('**/Gemfile.lock') }}
12+
restore-keys: ${{ runner.os }}-${{ env.ImageVersion }}-gem-
13+
- name: Cache Mint
14+
uses: actions/cache@v2
15+
id: mint-cache
16+
with:
17+
path: ~/.mint
18+
key: ${{ runner.os }}-${{ env.ImageVersion }}-mint-${{ hashFiles('**/Mintfile') }}
19+
restore-keys: ${{ runner.os }}-${{ env.ImageVersion }}-mint-
20+
- run: ./Scripts/bootstrap.sh
21+
shell: bash

.github/actions/set-build-image-var/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ description: 'Sets $ImageVersion with buil image version'
33
runs:
44
using: "composite"
55
steps:
6-
- run: echo "ImageVersion=$ImageVersion" >> $GITHUB_ENV
7-
shell: bash
6+
- run: echo "ImageVersion=$ImageVersion" >> $GITHUB_ENV
7+
shell: bash

.github/workflows/smoke-checks.yml

Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -23,55 +23,26 @@ jobs:
2323
name: Automated Code Review
2424
runs-on: macos-12
2525
steps:
26-
- uses: actions/checkout@v1
27-
- uses: ./.github/actions/set-build-image-var
28-
- name: Cache RubyGems
29-
uses: actions/cache@v2
30-
id: rubygem-cache
31-
with:
32-
path: vendor/bundle
33-
key: ${{ runner.os }}-${{ env.ImageVersion }}-gem-${{ hashFiles('**/Gemfile.lock') }}
34-
restore-keys: ${{ runner.os }}-${{ env.ImageVersion }}-gem-
35-
- name: Cache Mint
36-
uses: actions/cache@v2
37-
id: mint-cache
38-
with:
39-
path: /usr/local/lib/mint
40-
key: ${{ runner.os }}-mint-${{ hashFiles('./Mintfile') }}
41-
restore-keys: ${{ runner.os }}-mint-
42-
- uses: ./.github/actions/bootstrap
43-
- name: Run Danger
44-
run: bundle exec danger
45-
env:
46-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47-
- name: Run Linting
48-
run: ./Scripts/run-linter.sh
26+
- uses: actions/checkout@v1
27+
- uses: ./.github/actions/set-build-image-var
28+
- uses: ./.github/actions/bootstrap
29+
- name: Run Danger
30+
run: bundle exec danger
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
- name: Run Linting
34+
run: ./Scripts/run-linter.sh
4935

5036
build-and-test-ui-debug:
5137
name: Test SwiftUI (Debug)
5238
runs-on: macos-12
5339
steps:
5440
- uses: actions/checkout@v1
55-
- name: Set build image var
56-
run: echo "ImageVersion=$ImageVersion" >> $GITHUB_ENV
41+
- uses: ./.github/actions/set-build-image-var
5742
- uses: actions/[email protected]
5843
with:
5944
python-version: 3.8
6045
cache: 'pip'
61-
- name: Cache RubyGems
62-
uses: actions/cache@v2
63-
id: rubygem-cache
64-
with:
65-
path: vendor/bundle
66-
key: ${{ runner.os }}-${{ env.ImageVersion }}-gem-${{ hashFiles('**/Gemfile.lock') }}
67-
restore-keys: ${{ runner.os }}-${{ env.ImageVersion }}-gem-
68-
- name: Cache Mint
69-
uses: actions/cache@v2
70-
id: mint-cache
71-
with:
72-
path: /usr/local/lib/mint
73-
key: ${{ runner.os }}-mint-${{ hashFiles('./Mintfile') }}
74-
restore-keys: ${{ runner.os }}-mint-
7546
- uses: ./.github/actions/bootstrap
7647
env:
7748
INSTALL_SONAR: true
@@ -110,22 +81,7 @@ jobs:
11081
runs-on: macos-12
11182
steps:
11283
- uses: actions/checkout@v1
113-
- name: Set build image var
114-
run: echo "ImageVersion=$ImageVersion" >> $GITHUB_ENV
115-
- name: Cache RubyGems
116-
uses: actions/cache@v2
117-
id: rubygem-cache
118-
with:
119-
path: vendor/bundle
120-
key: ${{ runner.os }}-${{ env.ImageVersion }}-gem-${{ hashFiles('**/Gemfile.lock') }}
121-
restore-keys: ${{ runner.os }}-${{ env.ImageVersion }}-gem-
122-
- name: Cache Mint
123-
uses: actions/cache@v2
124-
id: mint-cache
125-
with:
126-
path: /usr/local/lib/mint
127-
key: ${{ runner.os }}-mint-${{ hashFiles('./Mintfile') }}
128-
restore-keys: ${{ runner.os }}-mint-
84+
- uses: ./.github/actions/set-build-image-var
12985
- uses: ./.github/actions/bootstrap
13086
- name: Build Demo App
13187
run: bundle exec fastlane build_demo

bootstrap.sh renamed to Scripts/bootstrap.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/usr/bin/env bash
22
# Usage: ./bootstrap.sh
3-
# This script will install Mint and bootstrap its dependencies, link git hooks and install required ruby gems.
3+
# This script will:
4+
# - install Mint and bootstrap its dependencies
5+
# - link git hooks
6+
# - install required ruby gems
7+
# - install sonar dependencies if `INSTALL_SONAR` environment variable is provided
48
# You should have homebrew installed.
59
# If you get `zsh: permission denied: ./bootstrap.sh` error, please run `chmod +x bootstrap.sh` first
610

@@ -11,17 +15,16 @@ function puts {
1115

1216
# Check if Homebrew is installed
1317
if [[ $(command -v brew) == "" ]]; then
14-
echo "Homebrew not installed. Please install."
15-
exit 1
18+
echo "Homebrew not installed. Please install."
19+
exit 1
1620
fi
1721

1822
set -Eeuo pipefail
1923

2024
trap "echo ; echo ❌ The Bootstrap script failed to finish without error. See the log above to debug. ; echo" ERR
2125

2226
puts "Install Mint if needed"
23-
# List installed Mint versions, if fails, install Mint
24-
brew list mint || brew install mint
27+
brew install mint
2528

2629
# Set bash to Strict Mode (http://redsymbol.net/articles/unofficial-bash-strict-mode/)
2730
set -euo pipefail
@@ -44,7 +47,7 @@ puts "Install bundle dependencies"
4447
bundle install
4548

4649
if [[ ${INSTALL_SONAR-default} == true ]]; then
47-
puts "Install sonar dependencies"
48-
pip install lizard
49-
brew install sonar-scanner
50+
puts "Install sonar dependencies"
51+
pip install lizard
52+
brew install sonar-scanner
5053
fi

StreamChatSwiftUI.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@
15661566
);
15671567
runOnlyForDeploymentPostprocessing = 0;
15681568
shellPath = /bin/sh;
1569-
shellScript = "if which mint >/dev/null && mint which swiftgen; then\n xcrun --sdk macosx mint run swiftgen config run --config Sources/StreamChatSwiftUI/.swiftgen.yml\nelse\n echo \"Warning: Bootstrap not run, please run ./bootstrap.sh\"\nfi\n";
1569+
shellScript = "if which mint >/dev/null && mint which swiftgen; then\n xcrun --sdk macosx mint run swiftgen config run --config Sources/StreamChatSwiftUI/.swiftgen.yml\nelse\n echo \"Warning: Bootstrap not run, please run ./Scripts/bootstrap.sh\"\nfi\n";
15701570
};
15711571
/* End PBXShellScriptBuildPhase section */
15721572

0 commit comments

Comments
 (0)