Skip to content

Commit 1f88907

Browse files
jamesnroktclaude
andauthored
ci: add trunk (#285)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e4105e2 commit 1f88907

7 files changed

Lines changed: 302 additions & 145 deletions

File tree

.github/workflows/pull-request.yml

Lines changed: 159 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Build and Test"
1+
name: 'Build and Test'
22

33
on:
44
pull_request:
@@ -15,159 +15,173 @@ permissions:
1515
id-token: write
1616

1717
jobs:
18-
js-tests:
19-
name: "JS Tests"
20-
runs-on: ubuntu-latest
21-
steps:
22-
- name: "Checkout"
18+
trunk-check:
19+
name: 'Trunk Check'
20+
runs-on: ubuntu-latest
21+
permissions:
22+
checks: write
23+
contents: read
24+
pull-requests: read
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v6
28+
- name: Trunk Check
29+
uses: trunk-io/trunk-action@v1
30+
31+
js-tests:
32+
name: 'JS Tests'
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: 'Checkout'
2336
uses: actions/checkout@v6
2437
- uses: actions/setup-node@v6.2.0
2538
with:
2639
node-version: 24
2740
cache: yarn
2841
cache-dependency-path: yarn.lock
2942

30-
- name: "Install node modules"
43+
- name: 'Install node modules'
3144
run: |
3245
yarn install
33-
34-
- name: "Run test"
46+
47+
- name: 'Run test'
3548
run: |
3649
yarn test
3750
38-
android-unit-tests:
39-
name: "Android Unit Tests"
40-
runs-on: ubuntu-latest
41-
steps:
42-
- name: "Checkout"
43-
uses: actions/checkout@v6
44-
- name: "Run Android Unit Tests"
45-
working-directory: android
46-
run: ./gradlew test
47-
48-
android-lint:
49-
name: "Android Lint"
50-
runs-on: ubuntu-latest
51-
steps:
52-
- name: "Checkout"
53-
uses: actions/checkout@v6
54-
- name: "Run Android lint"
55-
working-directory: android
56-
run: ./gradlew lint
57-
58-
android-kotlin-lint:
59-
name: "Android kotlin lint"
60-
runs-on: ubuntu-latest
61-
steps:
62-
- name: "Checkout"
63-
uses: actions/checkout@v6
64-
- name: "Run Android kotlin lint"
65-
working-directory: android
66-
run: ./gradlew ktlintCheck
67-
68-
android-sample-app:
69-
name: Android Sample App
70-
runs-on: ubuntu-latest
71-
steps:
72-
- name: Checkout
73-
uses: actions/checkout@v6
74-
- uses: actions/setup-node@v6.2.0
75-
with:
76-
node-version: 24
77-
cache: yarn
78-
cache-dependency-path: yarn.lock
79-
80-
- name: Install node modules
81-
run: yarn install
82-
83-
- name: Build package
84-
run: yarn dev:pack
85-
86-
- name: Install sample app dependencies
87-
working-directory: sample
88-
run: |
89-
rm -f yarn.lock
90-
yarn install
91-
92-
- name: Run Android sample app
93-
working-directory: sample/android
94-
run: ./gradlew assembleDebug
95-
96-
ios-sample-app:
97-
name: iOS Sample App
98-
runs-on: macos-15
99-
steps:
100-
- name: Checkout
101-
uses: actions/checkout@v6
102-
- uses: actions/setup-node@v6.2.0
103-
with:
104-
node-version: 24
105-
cache: yarn
106-
cache-dependency-path: yarn.lock
107-
108-
- name: Set up Xcode
109-
uses: maxim-lobanov/setup-xcode@v1.6.0
110-
with:
111-
xcode-version: latest-stable
112-
113-
- name: Set Xcode Toolchain
114-
run: echo "TOOLCHAINS=com.apple.dt.toolchain.XcodeDefault" >> $GITHUB_ENV
115-
116-
- name: Setup iOS Simulator
117-
uses: futureware-tech/simulator-action@v5
118-
id: simulator
119-
with:
120-
model: iPhone 16
121-
os: iOS
122-
os_version: ">=18.0"
123-
wait_for_boot: true
124-
shutdown_after_job: true
125-
126-
- name: Install node modules
127-
run: yarn install
128-
129-
- name: Build package
130-
run: yarn dev:pack
131-
132-
- name: Install sample app dependencies
133-
working-directory: sample
134-
run: |
135-
rm -f yarn.lock
136-
yarn install
137-
138-
- name: Install Ruby dependencies
139-
working-directory: sample
140-
run: bundle install
141-
142-
- name: Build iOS sample app
143-
working-directory: sample/ios
144-
run: |
145-
bundle exec pod install
146-
set -o pipefail && xcodebuild -workspace MParticleSample.xcworkspace \
147-
-configuration Debug \
148-
-scheme MParticleSample \
149-
-destination 'id=${{ steps.simulator.outputs.udid }}' \
150-
-derivedDataPath ios/build \
151-
-UseModernBuildSystem=YES \
152-
build | bundle exec xcpretty -k
153-
154-
pr-notify:
155-
if: >
156-
github.event_name == 'pull_request' &&
157-
github.event.pull_request.draft == false
158-
needs:
159-
- android-unit-tests
160-
- android-lint
161-
- android-kotlin-lint
162-
- android-sample-app
163-
- ios-sample-app
164-
- js-tests
165-
name: Notify GChat
166-
uses: ROKT/rokt-workflows/.github/workflows/oss_pr_opened_notification.yml@main
167-
secrets:
168-
gchat_webhook: ${{ secrets.GCHAT_PRS_WEBHOOK }}
169-
170-
automerge-dependabot:
171-
name: "Save PR Number for Dependabot Automerge"
172-
needs: [ js-tests, android-unit-tests, android-lint, android-kotlin-lint ]
173-
uses: mParticle/mparticle-workflows/.github/workflows/dependabot-save-pr-number.yml@main
51+
android-unit-tests:
52+
name: 'Android Unit Tests'
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: 'Checkout'
56+
uses: actions/checkout@v6
57+
- name: 'Run Android Unit Tests'
58+
working-directory: android
59+
run: ./gradlew test
60+
61+
android-lint:
62+
name: 'Android Lint'
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: 'Checkout'
66+
uses: actions/checkout@v6
67+
- name: 'Run Android lint'
68+
working-directory: android
69+
run: ./gradlew lint
70+
71+
android-kotlin-lint:
72+
name: 'Android kotlin lint'
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: 'Checkout'
76+
uses: actions/checkout@v6
77+
- name: 'Run Android kotlin lint'
78+
working-directory: android
79+
run: ./gradlew ktlintCheck
80+
81+
android-sample-app:
82+
name: Android Sample App
83+
runs-on: ubuntu-latest
84+
steps:
85+
- name: Checkout
86+
uses: actions/checkout@v6
87+
- uses: actions/setup-node@v6.2.0
88+
with:
89+
node-version: 24
90+
cache: yarn
91+
cache-dependency-path: yarn.lock
92+
93+
- name: Install node modules
94+
run: yarn install
95+
96+
- name: Build package
97+
run: yarn dev:pack
98+
99+
- name: Install sample app dependencies
100+
working-directory: sample
101+
run: |
102+
rm -f yarn.lock
103+
yarn install
104+
105+
- name: Run Android sample app
106+
working-directory: sample/android
107+
run: ./gradlew assembleDebug
108+
109+
ios-sample-app:
110+
name: iOS Sample App
111+
runs-on: macos-15
112+
steps:
113+
- name: Checkout
114+
uses: actions/checkout@v6
115+
- uses: actions/setup-node@v6.2.0
116+
with:
117+
node-version: 24
118+
cache: yarn
119+
cache-dependency-path: yarn.lock
120+
121+
- name: Set up Xcode
122+
uses: maxim-lobanov/setup-xcode@v1.6.0
123+
with:
124+
xcode-version: latest-stable
125+
126+
- name: Set Xcode Toolchain
127+
run: echo "TOOLCHAINS=com.apple.dt.toolchain.XcodeDefault" >> $GITHUB_ENV
128+
129+
- name: Setup iOS Simulator
130+
uses: futureware-tech/simulator-action@v5
131+
id: simulator
132+
with:
133+
model: iPhone 16
134+
os: iOS
135+
os_version: '>=18.0'
136+
wait_for_boot: true
137+
shutdown_after_job: true
138+
139+
- name: Install node modules
140+
run: yarn install
141+
142+
- name: Build package
143+
run: yarn dev:pack
144+
145+
- name: Install sample app dependencies
146+
working-directory: sample
147+
run: |
148+
rm -f yarn.lock
149+
yarn install
150+
151+
- name: Install Ruby dependencies
152+
working-directory: sample
153+
run: bundle install
154+
155+
- name: Build iOS sample app
156+
working-directory: sample/ios
157+
run: |
158+
bundle exec pod install
159+
set -o pipefail && xcodebuild -workspace MParticleSample.xcworkspace \
160+
-configuration Debug \
161+
-scheme MParticleSample \
162+
-destination 'id=${{ steps.simulator.outputs.udid }}' \
163+
-derivedDataPath ios/build \
164+
-UseModernBuildSystem=YES \
165+
build | bundle exec xcpretty -k
166+
167+
pr-notify:
168+
if: >
169+
github.event_name == 'pull_request' &&
170+
github.event.pull_request.draft == false
171+
needs:
172+
- trunk-check
173+
- android-unit-tests
174+
- android-lint
175+
- android-kotlin-lint
176+
- android-sample-app
177+
- ios-sample-app
178+
- js-tests
179+
name: Notify GChat
180+
uses: ROKT/rokt-workflows/.github/workflows/oss_pr_opened_notification.yml@main
181+
secrets:
182+
gchat_webhook: ${{ secrets.GCHAT_PRS_WEBHOOK }}
183+
184+
automerge-dependabot:
185+
name: 'Save PR Number for Dependabot Automerge'
186+
needs: [js-tests, android-unit-tests, android-lint, android-kotlin-lint]
187+
uses: mParticle/mparticle-workflows/.github/workflows/dependabot-save-pr-number.yml@main
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Run trunk upgrade
2+
3+
on:
4+
workflow_call:
5+
schedule:
6+
- cron: 0 0 1 * *
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
generate-and-call-upgrade:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
generated-token: ${{ steps.generate-token.outputs.token }}
18+
steps:
19+
- name: Generate a token
20+
id: generate-token
21+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
22+
with:
23+
app-id: ${{ secrets.SDK_RELEASE_GITHUB_APP_ID }} # trunk-ignore(actionlint/expression)
24+
private-key: ${{ secrets.SDK_RELEASE_GITHUB_APP_PRIVATE_KEY }} # trunk-ignore(actionlint/expression)
25+
owner: ${{ github.repository_owner }}
26+
repositories: |
27+
react-native-mparticle
28+
29+
trunk-upgrade:
30+
needs: generate-and-call-upgrade
31+
name: Run trunk upgrade
32+
uses: ROKT/rokt-workflows/.github/workflows/trunk-upgrade.yml@main # trunk-ignore(actionlint/workflow-call)
33+
with:
34+
token: ${{ needs.generate-and-call-upgrade.outputs.generated-token }}

.trunk/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*out
2+
*logs
3+
*actions
4+
*notifications
5+
*tools
6+
plugins
7+
user_trunk.yaml
8+
user.yaml
9+
tmp

.trunk/configs/.markdownlint.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Autoformatter friendly markdownlint config (all formatting rules disabled)
2+
default: true
3+
blank_lines: false
4+
bullet: false
5+
html: false
6+
indentation: false
7+
line_length: false
8+
spaces: false
9+
url: false
10+
whitespace: false

.trunk/configs/.shellcheckrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
enable=all
2+
source-path=SCRIPTDIR
3+
disable=SC2154
4+
5+
# If you're having issues with shellcheck following source, disable the errors via:
6+
# disable=SC1090
7+
# disable=SC1091

.trunk/configs/.yamllint.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
rules:
2+
quoted-strings:
3+
required: only-when-needed
4+
extra-allowed: ['{|}']
5+
empty-values:
6+
forbid-in-block-mappings: true
7+
forbid-in-flow-mappings: true
8+
key-duplicates: {}
9+
octal-values:
10+
forbid-implicit-octal: true

0 commit comments

Comments
 (0)