Start Adding GitHub Actions (#1165)

Summary:
This change starts adding more coverage to GitHub Actions. Existing workflows are split up to be per-platform, and stale scripts, etc are removed.

We are currently limited a bit by issues with the build itself, but this still adds a good bit of coverage that readily works, and adds places to inject more.

Another option would have been to move these to CircleCI where we have more credits, or used docker images instead of manual setup steps. etc, The Yoga build and number of changes is very light though, so we don't really need the complexity yet.

Some TODOs:
1. Fix the Apple Builds (pod lint and pod install return errors seen by the community)
2. Add working Android UTs
3. Add C++ UTs
4. Add Apple Publish
5. Add version stamping

Changelog:
[Internal][Added] - Start Adding Yoga GitHub Actions

Pull Request resolved: https://github.com/facebook/yoga/pull/1165

Reviewed By: cortinico

Differential Revision: D40386426

Pulled By: NickGerleman

fbshipit-source-id: c540dd25bfec6ac8c05e461c1236ef7fe6cb8598
This commit is contained in:
Nick Gerleman
2022-10-17 23:35:01 -07:00
committed by Facebook GitHub Bot
parent c2a0ccf0d4
commit e9184c793e
22 changed files with 349 additions and 272 deletions

24
.github/actions/clang-format/action.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
name: Clang Format
inputs:
directory:
description: Directory to Lint
required: true
version:
description: LLVM version to use # Should be kept roughly in sync with arcanist
required: false
default: 12
runs:
using: "composite"
steps:
- name: Install
shell: bash
run: sudo apt-get install -y clang-format-${{ inputs.version }}
- name: clang-format
working-directory: ${{ inputs.directory }}
shell: bash
run: |
shopt -s globstar
shopt -s nullglob
clang-format-${{ inputs.version }} --dry-run --Werror **/*.cpp **/*.h **/*.m **/*.mm

View File

@@ -0,0 +1,13 @@
name: Setup Android envirionment
runs:
using: "composite"
steps:
- name: Install JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Install NDK 21
shell: bash
run: echo "y" | /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT}

View File

@@ -0,0 +1,9 @@
name: Setup Apple envirionment
runs:
using: "composite"
steps:
# TODO: This and Ruby should be versioned
- name: Install Cocoapods
shell: bash
run: sudo gem install cocoapods

View File

@@ -0,0 +1,14 @@
name: Setup Website envirionment
runs:
using: "composite"
steps:
- name: Install NodeJS 12
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: yarn install
shell: bash
run: yarn install --frozen-lockfile
working-directory: website

View File

@@ -1,58 +0,0 @@
name: CI
on: [push, pull_request]
jobs:
website:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts
working-directory: website
- name: Build
run: yarn build
working-directory: website
- name: Deploy
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: website/public
cname: yogalayout.com
keep_files: true
user_name: 'Yoga-bot'
user_email: 'yogabot@fb.com'
android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Install NDK 21
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}
- name: Install dependencies
run: |
if [[ -n "${{ secrets.encrypted_d27e803291ff_iv }}" ]]; then
openssl aes-256-cbc -K ${{ secrets.encrypted_d27e803291ff_key }} -iv {{ secrets.encrypted_d27e803291ff_iv }} -in scripts/setup-keys.enc -d >> gradle.properties;
fi
sudo apt-get update
sudo apt-get install -y ninja-build
pushd $HOME
git clone --depth 1 https://github.com/facebook/buck.git
cd buck
ant
popd
echo "$HOME/buck/bin" >> $GITHUB_PATH
export PATH=$PATH:$HOME/buck/bin/
buck --version
- name: Build
# TODO: Run the tests here again. They're currently crashing the JVM in GitHub Actions for some reason.
run: ./gradlew :yoga-layout:assembleDebug

29
.github/workflows/publish-android.yml vendored Normal file
View File

@@ -0,0 +1,29 @@
name: Android
on:
release:
types:
- created
workflow_dispatch:
jobs:
publish:
name: Publish to Maven Central
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-android
- name: Publish and release
run: |
./gradlew :yoga:assembleRelease publish --info
./gradlew closeAndReleaseRepository
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}

32
.github/workflows/publish-website.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: Website
on:
push:
branches:
- main
workflow_dispatch:
jobs:
publish:
name: Publish to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-website
- name: yarn build
run: yarn build
working-directory: website
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: website/public
cname: yogalayout.com
keep_files: true
user_name: 'Yoga-bot'
user_email: 'yogabot@fb.com'

View File

@@ -1,32 +0,0 @@
name: Publish
on:
release:
types:
- created
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Install dependencies
run: source scripts/android-setup.sh && installAndroidSDK
- name: Write GPG Sec Ring
run: echo '${{ secrets.GPG_KEY_CONTENTS }}' | base64 -d > /tmp/secring.gpg
- name: Update gradle.properties
run: echo -e "signing.secretKeyRingFile=/tmp/secring.gpg\nsigning.keyId=${{ secrets.SIGNING_KEY_ID }}\nsigning.password=${{ secrets.SIGNING_PASSWORD }}\nmavenCentralPassword=${{ secrets.SONATYPE_NEXUS_PASSWORD }}\nmavenCentralUsername=${{ secrets.SONATYPE_NEXUS_USERNAME }}" >> gradle.properties
- name: Upload Android Archives
run: ./gradlew :yoga:assembleRelease publish --info
- name: Release and close
run: ./gradlew closeAndReleaseRepository
- name: Clean secrets
if: always()
run: rm /tmp/secring.gpg

20
.github/workflows/validate-android.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Android
on: [push, pull_request, workflow_dispatch]
jobs:
build:
name: Build (${{ matrix.mode }})
runs-on: ubuntu-latest
strategy:
matrix:
mode: [Debug, Release]
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-android
- name: Build
run: ./gradlew assemble${{ matrix.mode }}

50
.github/workflows/validate-apple.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Apple
on: [push, pull_request, workflow_dispatch]
jobs:
lint-pods:
name: Lint
if: ${{ false }} # Apple Build is Broken
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-apple
- name: pod spec lint
run: pod spec lint --verbose
build-sample:
name: Build (${{ matrix.mode }})
if: ${{ false }} # Apple Build is Broken
runs-on: macos-latest
strategy:
matrix:
mode: [Debug, Release]
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-apple
- name: pod install
working-directory: ./YogaKit/YogaKitSample
run: pod install
# TODO: xcodebuild
clang-format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: clang-format
uses: ./.github/actions/clang-format
with:
directory: ./YogaKit

16
.github/workflows/validate-cpp.yml vendored Normal file
View File

@@ -0,0 +1,16 @@
name: C++
on: [push, pull_request, workflow_dispatch]
jobs:
clang-format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: clang-format
uses: ./.github/actions/clang-format
with:
directory: ./yoga

18
.github/workflows/validate-website.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
name: Website
on: [push, pull_request, workflow_dispatch]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-website
- name: yarn build
run: yarn build
working-directory: website