forked from signalapp/Signal-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (101 loc) · 4.41 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: CI
on:
pull_request:
push:
branches:
- main
- release/*
jobs:
build_and_test:
name: Build and Test
runs-on: macos-11
steps:
- name: Setup environment
shell: bash
run: |
# Set this if there's a code change that requires a newer Xcode than the default
REQUIRED_VERSION=13.0
CURRENT_VERSION=$(xcodebuild -version | grep "Xcode" | awk '{print $2}')
echo "Current Xcode version: $CURRENT_VERSION"
echo "Required Xcode version: $REQUIRED_VERSION"
if [[ $CURRENT_VERSION < $REQUIRED_VERSION ]]; then
# Path format pulled from https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md#xcode
NEW_XCODE="/Applications/Xcode_$REQUIRED_VERSION.app"
echo "Updating selected Xcode to $NEW_XCODE"
sudo xcode-select -s $NEW_XCODE
CURRENT_VERSION=$(xcodebuild -version | grep "Xcode" | awk '{print $2}')
echo "$?: Current Xcode version: $CURRENT_VERSION"
fi
- name: Checkout Repo
uses: actions/checkout@v2
with:
# Check out submodules through GitHub instead of from scratch later.
# THIS STEP WILL FAIL if the current Pods commit is only available in Private.
# However, we can continue and the build will still pass.
submodules: recursive
continue-on-error: true
- name: Initialize workflow variables
id: vars
shell: bash
run: |
# check for ACCESS_TOKEN availability (work-around for inaccessible 'secrets' object for 'if'; see <https://github.community/t5/GitHub-Actions/jobs-lt-job-id-gt-if-does-not-work-with-env-secrets/m-p/38549>)
if [ -z $ACCESS_TOKEN ]; then unset HAS_ACCESS_TOKEN ; else HAS_ACCESS_TOKEN='true' ; fi
echo ::set-output name=HAS_ACCESS_TOKEN::${HAS_ACCESS_TOKEN}
env:
ACCESS_TOKEN: "${{ secrets.ACCESS_TOKEN }}"
# Checkout private pods repo iff we have an access token to read private repos
- name: Checkout Private Pods
uses: actions/checkout@v2
# if: secrets.ACCESS_TOKEN (not supported {yet?}; see <https://github.community/t5/GitHub-Actions/jobs-lt-job-id-gt-if-does-not-work-with-env-secrets/m-p/38549>)
if: steps.vars.outputs.HAS_ACCESS_TOKEN
with:
repository: signalapp/signal-pods-private
token: ${{ secrets.ACCESS_TOKEN }}
path: Pods
# We don't know which commit we'll need in this step, so fetch everything so that
# `make dependencies` doesn't end up doing it the slow way.
fetch-depth: 0
- name: Initialize Submodules
run: make dependencies
- name: Setup Ruby
uses: ruby/setup-ruby@v1 # Reads .ruby-version file by default
- name: Cache Bundle Install
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Bundle Install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Build and Test
run: |
function formatFailures() {
grep '<failure message' fastlane/test_output/report.junit | sed -E "s/^.*<failure message='(.*)'>(.*):([0-9]+)<\/failure>/::error file=\2,line=\3::\1/" | sed -E 's/"/"/g'
exit 1
}
bundle exec fastlane scan --scheme Signal --output_types junit || formatFailures
- name: Upload build logs
uses: actions/upload-artifact@v2
if: failure()
with:
name: Logs
path: ~/Library/Logs/scan
lint:
name: Lint
runs-on: macos-11
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v2
- name: Fetch base commit
run: git fetch origin --depth 1 ${{ github.base_ref }}
- name: Install Dependencies
run: brew install clang-format python3
- name: Lint files changed in the PR
run: |
python3 Scripts/precommit.py --ref origin/${{ github.base_ref }}
# https://help.github.com/en/actions/reference/development-tools-for-github-actions#logging-commands
git diff --name-only | sed -E 's|(.*)|::error file=\1::Incorrectly formatted (Scripts/precommit.py)|'
git diff --quiet || exit 1