Skip to content

ci: harden pipeline #260

ci: harden pipeline

ci: harden pipeline #260

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Test
on:
push:
branches: ['main']
pull_request:
branches: ['main']
jobs:
npm-compatibility-check:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
registry.npmjs.org:443
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup NodeJS
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: lts/*
# Cache not enabled to test if npm can load and resolve everything
- name: Remove engine restrictions to enable use of npm
run: npm pkg delete engines
- run: npm i
test-web:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
registry.yarnpkg.com:443
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup NodeJS
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: lts/*
- name: Cache node_modules
id: node-modules
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
node_modules
example/node_modules
.yarn/cache
key: node-modules
- run: yarn
- run: yarn test
test-ios:
runs-on: macos-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup NodeJS
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: lts/*
- uses: ruby/setup-ruby@28c4deda893d5a96a6b2d958c5b47fc18d65c9d3 # v1.213.0
with:
ruby-version: '3.3'
bundler-cache: true
- name: 'Get Ruby Version'
run: ruby --version
- uses: SwiftyLab/setup-swift@5825efd16e0e9f41c4e9b94658b7973e16410d5b # latest
with:
swift-version: '5.10.0'
- name: Get Swift Version
run: swift --version
- name: Get Xcode version
env:
DEVELOPER_DIR: /Applications/Xcode_15.4.app
run: xcodebuild -version
- name: Cache Pods
id: pods
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
example/ios/Pods
key: pods
- name: Cache node_modules
id: node-modules
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
node_modules
example/node_modules
.yarn/cache
key: node-modules
- name: Cache Xcode DerivedData
uses: irgaly/xcode-cache@b2efce08537a035a11795bd6dde030d1208b00b3 # v1.7.2
with:
key: xcode-deriveddata
restore-keys: xcode-deriveddata
- run: corepack enable
- run: yarn
- run: cd example; bundle; cd -
- run: cd example/ios; bundle exec pod install; cd -
- name: Run Tests
env:
DEVELOPER_DIR: /Applications/Xcode_15.4.app
run: make test-ios
test-android:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
dl.google.com:443
github.com:443
objects.githubusercontent.com:443
oss.sonatype.org:443
plugins-artifacts.gradle.org:443
plugins.gradle.org:443
registry.npmjs.org:443
registry.yarnpkg.com:443
repo.maven.apache.org:443
repo.yarnpkg.com:443
services.gradle.org:443
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up JDK 17
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Android SDK
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
- name: Setup Nodejs
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: lts/*
- name: Cache node_modules
id: node-modules
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
node_modules
example/node_modules
.yarn/cache
key: node-modules
- name: Cache Gradle
id: cache_gradle
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
.gradle
example/android/.gradle
~/.gradle/caches
key: gradle
- run: |
corepack enable
yarn
- name: Run Gradle
if: steps.cache_gradle.outputs.cache-hit != 'true'
run: example/android/gradlew
- name: Run Tests
run: make test-android