Skip to content

Commit

Permalink
chore: polish CI (#1)
Browse files Browse the repository at this point in the history
* test ci

* typo

* test

* unify build

* fix export task, missing needs

* fix typo runner.os instead of matrix.os

* fix macos export

* fix
leanmendoza authored May 23, 2023
1 parent 1b08fc5 commit 471b91d
Showing 1 changed file with 60 additions and 82 deletions.
142 changes: 60 additions & 82 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
release:
types:
- created

name: Test and build CI
name: CI

jobs:
lints:
@@ -58,7 +65,16 @@ jobs:
override: true
components: llvm-tools-preview

- uses: Swatinem/rust-cache@v1
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
rust/Cargo.lock
key: coverage-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: coverage-cargo-

- name: Download grcov
run: |
@@ -75,12 +91,12 @@ jobs:
with:
files: rust/coverage/*.lcov

build-win-linux:
name: Build on Windows and Linux
if: ${{ github.ref == 'refs/heads/main' }}
build:
name: Build and test
# if: ${{ github.ref == 'refs/heads/main' }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
os: [windows-latest, ubuntu-latest, macos-latest]
rust: [stable]
runs-on: ${{ matrix.os }}
steps:
@@ -93,7 +109,8 @@ jobs:
~/.cargo/git
rust/target
rust/Cargo.lock
key: ${{ matrix.os }}-cargo
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ matrix.os }}-cargo-
- uses: actions-rs/toolchain@v1
with:
profile: minimal
@@ -103,84 +120,59 @@ jobs:
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up target platform
if: ${{ matrix.os == 'macos-latest' }}
run: |
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
- uses: actions-rs/cargo@v1
name: cargo test
with:
command: test
args: --manifest-path rust/Cargo.toml --release

- uses: actions-rs/cargo@v1
if: ${{ matrix.os != 'macos-latest' }}
name: cargo build
with:
command: build
args: --manifest-path rust/Cargo.toml --release
- uses: actions/upload-artifact@master
with:
name: decentraland-godot-lib-${{ matrix.os }}
path: |
rust/target/release/decentraland_godot_lib.dll
rust/target/release/libdecentraland_godot_lib.so
build-macos:
name: Build on MacOS
runs-on: macos-latest
if: ${{ github.ref == 'refs/heads/main' }}
strategy:
matrix:
target: [x86_64-apple-darwin, aarch64-apple-darwin]
steps:
- uses: actions/checkout@v2
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
rust/Cargo.lock
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.target }}-cargo-
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: ${{ matrix.target }}
- name: Install protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions-rs/cargo@v1
name: cargo test
if: ${{ matrix.target }} == "x86_64-apple-darwin" # the actino is cross-compiling the aarch64 target
name: build for x86_64 (macos)
if: ${{ matrix.os == 'macos-latest' }}
with:
command: test
args: --manifest-path rust/Cargo.toml --release
command: build
args: --manifest-path rust/Cargo.toml --release --target=x86_64-apple-darwin

- uses: actions-rs/cargo@v1
name: cargo build
name: build for arm64 (macos)
if: ${{ matrix.os == 'macos-latest' }}
with:
command: build
args: --manifest-path rust/Cargo.toml --release --target=${{ matrix.target }}

- name: print ls
run: ls rust/target
args: --manifest-path rust/Cargo.toml --release --target=aarch64-apple-darwin

- name: Make universal library
if: ${{ matrix.os == 'macos-latest' }}
run: |
mkdir rust/target/release || true
lipo -create rust/target/x86_64-apple-darwin/release/libdecentraland_godot_lib.dylib rust/target/aarch64-apple-darwin/release/libdecentraland_godot_lib.dylib -output rust/target/release/libdecentraland_godot_lib.dylib
- uses: actions/upload-artifact@master
with:
name: decentraland-godot-lib-${{ matrix.target }}
path: rust/target/${{ matrix.target }}/release/libdecentraland_godot_lib.dylib

name: decentraland-godot-lib-${{ matrix.os }}
path: |
rust/target/release/decentraland_godot_lib.dll
rust/target/release/libdecentraland_godot_lib.so
rust/target/release/libdecentraland_godot_lib.dylib
export:
name: Export
needs: [build-win-linux, build-macos]
name: Export (all platforms)
needs: build
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
# if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v2
- name: Download lipo
run: |
curl -L -o /tmp/lipo https://github.com/konoui/lipo/releases/latest/download/lipo_Linux_amd64
chmod +x /tmp/lipo
sudo mv /tmp/lipo /usr/local/bin
- name: Download linux lib artifact
uses: actions/download-artifact@master
with:
@@ -192,26 +184,12 @@ jobs:
with:
name: decentraland-godot-lib-windows-latest
path: godot/lib

- name: mkdir macos artifacts dest_path
run: |
mkdir godot/lib/aarch64-apple-darwin || true
mkdir godot/lib/x86_64-apple-darwin || true

- name: Download macos aarch64 lib artifact
- name: Download macos lib artifact
uses: actions/download-artifact@master
with:
name: decentraland-godot-lib-aarch64-apple-darwin
path: godot/lib/aarch64-apple-darwin

- name: Download macos x86_64 lib artifact
uses: actions/download-artifact@master
with:
name: decentraland-godot-lib-x86_64-apple-darwin
path: godot/lib/x86_64-apple-darwin

- name: lipo macos
run: lipo -create godot/lib/x86_64-apple-darwin/libdecentraland_godot_lib.dylib godot/lib/aarch64-apple-darwin/libdecentraland_godot_lib.dylib -output godot/lib/libdecentraland_godot_lib.dylib
name: decentraland-godot-lib-macos-latest
path: godot/lib

- name: export
id: export

0 comments on commit 471b91d

Please sign in to comment.