Skip to content

Commit 120e62d

Browse files
committed
Introduce testing on CI
1 parent ba7af2f commit 120e62d

File tree

5 files changed

+3217
-2
lines changed

5 files changed

+3217
-2
lines changed

.github/workflows/test.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: GitHub Actions
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
jobs:
8+
validation:
9+
name: Validation
10+
runs-on: macOS-11
11+
strategy:
12+
matrix:
13+
xcode_version:
14+
- "12.2"
15+
env:
16+
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Get ruby gem cache
21+
id: gem-cache
22+
uses: actions/cache@v2
23+
with:
24+
path: vendor/bundle
25+
key: ${{ runner.os }}-1-gem-${{ hashFiles('Gemfile.lock') }}
26+
restore-keys: ${{ runner.os }}-1-gem-
27+
28+
- name: Install ruby gems
29+
if: steps.gem-cache.cache.outputs.cache-hit != 'true'
30+
run: make gem
31+
32+
- name: Get SwiftPM cache
33+
uses: actions/cache@v2
34+
with:
35+
path: Tools/.build
36+
key: ${{ runner.os }}-${{ matrix.xcode_version }}-1-spm-${{ hashFiles('Tools/Package.resolved') }}
37+
restore-keys: ${{ runner.os }}-${{ matrix.xcode_version }}-1-spm-
38+
39+
- name: Podspec lint
40+
run: make pod-lib-lint
41+
42+
- name: Validation
43+
run: make all && [ -z "$(git status --porcelain)" ] && make lint
44+
env:
45+
SPM_FORCE_BUILD: 1
46+
47+
test:
48+
name: Test on macOS
49+
runs-on: macOS-11.0
50+
strategy:
51+
matrix:
52+
xcode_version:
53+
- "12.2"
54+
env:
55+
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
56+
steps:
57+
- uses: actions/checkout@v2
58+
- name: Show environments
59+
run: |
60+
swift --version
61+
xcodebuild -version
62+
63+
- name: Get ruby gem cache
64+
id: gem-cache
65+
uses: actions/cache@v2
66+
with:
67+
path: vendor/bundle
68+
key: ${{ runner.os }}-1-gem-${{ hashFiles('Gemfile.lock') }}
69+
restore-keys: ${{ runner.os }}-1-gem-
70+
71+
- name: Get npm cache
72+
id: npm-cache
73+
uses: actions/cache@v2
74+
with:
75+
path: node_modules
76+
key: ${{ runner.os }}-0-npm-${{ hashFiles('package-lock.json') }}
77+
restore-keys: ${{ runner.os }}-0-npm-
78+
79+
- name: Get CocoaPods cache
80+
id: cocoapods-cache
81+
uses: actions/cache@v2
82+
with:
83+
path: Pods
84+
key: ${{ runner.os }}-1-cocoapods-${{ hashFiles('Example/Podfile.lock') }}
85+
restore-keys: ${{ runner.os }}-1-cocoapods-
86+
87+
- name: Install npm packages
88+
if: steps.npm-cache.cache.outputs.cache-hit != 'true'
89+
run: make npm
90+
91+
- name: Install ruby gems
92+
if: steps.gem-cache.cache.outputs.cache-hit != 'true'
93+
run: make gem
94+
95+
- name: Install CocoaPods packages
96+
if: steps.cocoapods-cache.cache.outputs.cache-hit != 'true'
97+
run: pod-install
98+
99+
- name: Generate snapshots
100+
run: set -o pipefail && xcodebuild build-for-testing test-without-building -workspace Example/Example.xcworkspace -scheme SampleApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12 Pro' ENABLE_TESTABILITY=YES | xcpretty -c
101+
102+
- name: Visual regression test
103+
run: npx percy upload Snapshots
104+
env:
105+
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ proj:
1111

1212
.PHONY: pod-install
1313
pod-install:
14-
bundle exec pod install --project-directory=Example
14+
bundle exec pod install --project-directory=Example || bundle exec pod install --repo-update --project-directory=Example
1515

1616
.PHONY: mod
1717
mod:
@@ -38,6 +38,10 @@ gem:
3838
bundle config path vendor/bundle
3939
bundle install --jobs 4 --retry 3
4040

41+
.PHONY: npm
42+
npm:
43+
npm i
44+
4145
.PHONY: docs
4246
docs:
4347
$(SWIFT_TOOL) swift-doc generate Sources -n PlaybookAccessibilitySnapshot -f html -o docs

Tools/swift-run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CHECKSUM="$BIN_DIR/$PACKAGE_NAME.sha256"
1313

1414
shasum -a 256 -c $CHECKSUM && check=0 || check=1
1515

16-
if [[ ! -e $BIN || $check != 0 ]]; then
16+
if [[ ! -e $BIN || $check != 0 || "${SPM_FORCE_BUILD-0}" -gt 0 ]]; then
1717
echo "$PACKAGE_NAME is not installed"
1818
echo "Installing ..."
1919
$SWIFT_BUILD --product $PACKAGE_NAME

0 commit comments

Comments
 (0)