Skip to content

Commit

Permalink
Merge pull request #11 from boozook/ci/update-prebuild
Browse files Browse the repository at this point in the history
CI: add update bindings workflow
  • Loading branch information
boozook authored Sep 11, 2023
2 parents 9faf991 + c239a3e commit 6ab6ef9
Showing 1 changed file with 130 additions and 27 deletions.
157 changes: 130 additions & 27 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Update
on:
workflow_call:
# schedule:
# - cron: "0 0 * * 1"
# push:
# branches: [main, master]
workflow_dispatch:
schedule:
- cron: "0 0 * * 1"

env:
CARGO_INCREMENTAL: 1
Expand All @@ -17,31 +15,87 @@ env:
# allow modify source for bindings generator:
PD_BUILD_PREBUILT: 1

permissions:
contents: write

jobs:
pre-gen:
if: false # not ready yet
new-branch:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout Master
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}

- name: Create Branch
id: branch
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: refs/heads/api/sys/pre-build
# ${{ github.event.pull_request.head.sha }}
- name: Created
run: 'echo "Created: ${{ steps.branch.outputs.created }}"'

# TODO: do not reset, just rebase to master
# just try `git pull origin ${{github.event.repository.default_branch}}`
# and if failed => run ReSync

# if not created => rebase to master
- name: ReSync Branch
if: ${{ steps.branch.outputs.created == 'false' }}
uses: Joao208/[email protected]
with:
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: api/sys/pre-build
DEFAULT_BRANCH: ${{github.event.repository.default_branch}}

pre-gen:
name: Gen (${{ matrix.os }}, ${{ matrix.features.v }})
defaults:
run:
shell: bash
needs: new-branch
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
fail-fast: true
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
# - windows-latest
sdk:
- latest
features:
- --features=bindings-documentation,bindings-derive-debug
- --features=bindings-documentation,bindings-derive-default,bindings-derive-eq,bindings-derive-copy,bindings-derive-debug,bindings-derive-hash,bindings-derive-ord,bindings-derive-partialeq,bindings-derive-partialord
- {
v: --features=bindings-documentation,
bindings-derive-debug,
name: default,
}
- {
v: --features=bindings-documentation,
bindings-derive-default,
bindings-derive-eq,
bindings-derive-copy,
bindings-derive-debug,
bindings-derive-hash,
bindings-derive-ord,
bindings-derive-partialeq,
bindings-derive-partialord,
name: full,
}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: api/sys/pre-build

- name: Cache
uses: Swatinem/rust-cache@v1
uses: Swatinem/rust-cache@v2.6.2

- name: Install Playdate SDK ${{ matrix.sdk }}
id: sdk
Expand All @@ -56,27 +110,76 @@ jobs:

- name: Host
run: |
cargo build -p=playdate-sys ${{ matrix.features }} -vv
cargo build -p=playdate-sys ${{ matrix.features }} --release
cargo build -p=playdate-sys ${{ matrix.features.v }} -vv
cargo build -p=playdate-sys ${{ matrix.features.v }} --release
- name: Device
if: ${{ matrix.os }} == "ubuntu-latest"
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cargo build -p=playdate-sys ${{ matrix.features }} --target=thumbv7em-none-eabihf
cargo build -p=playdate-sys ${{ matrix.features }} --target=thumbv7em-none-eabihf --release
cargo build -p=playdate-sys ${{ matrix.features.v }} --target=thumbv7em-none-eabihf
cargo build -p=playdate-sys ${{ matrix.features.v }} --target=thumbv7em-none-eabihf --release
- name: Format
run: rustfmt ./api/sys/gen/*.rs
run: rustfmt api/sys/gen/*.rs

- name: Test (dev)
- name: Test (host)
# env: # uncomment when all bindings for min-supported-SDK will be there
# IGNORE_EXISTING_PLAYDATE_SDK: 1
run: |
cargo test -p=playdate-sys ${{ matrix.features }} --all-targets
cargo build -p=playdate-sys ${{ matrix.features }} --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc
cargo test -p=playdate-sys ${{ matrix.features.v }}
cargo test -p=playdate-sys ${{ matrix.features.v }} --release
- name: Test (release)
- name: Test (device)
if: ${{ matrix.os == 'ubuntu-latest' }}
# env: # uncomment when all bindings for min-supported-SDK will be there
# IGNORE_EXISTING_PLAYDATE_SDK: 1
run: |
cargo test -p=playdate-sys ${{ matrix.features }} --all-targets --release
cargo build -p=playdate-sys ${{ matrix.features }} --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc --release
# TODO: build tests for --target=thumbv7em-none-eabihf with -Zbuild-std=core,alloc and mb. restricted-std
cargo build -p=playdate-sys ${{ matrix.features.v }} --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc
cargo build -p=playdate-sys ${{ matrix.features.v }} --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc --release
- name: Commit
id: commit
uses: EndBug/add-and-commit@v9
with:
add: ./api/sys/gen/*.rs
author_name: Alex Koz
author_email: [email protected]
committer_name: Update Workflow
message: Automated build pre-built bindings
pull: "--rebase --autostash"
push: true

# TODO: compare, create PR
- name: Committed
run: |
echo "Committed: ${{ steps.commit.outputs.committed }}"
echo "Pushed: ${{ steps.commit.outputs.pushed }}"
echo "SHA: ${{ steps.commit.outputs.commit_sha }}"
pr:
name: Make PR
needs: pre-gen
runs-on: ubuntu-latest
defaults:
run:
shell: bash
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: api/sys/pre-build

- name: Create PR
uses: TreTuna/[email protected]
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
FROM_BRANCH: refs/heads/api/sys/pre-build
TO_BRANCH: ${{ github.event.repository.default_branch }}
PULL_REQUEST_TITLE: Update pre-built bindings
PULL_REQUEST_BODY: |
Pre-built bindings just updated.
Don't forget to bump version and make release.
PULL_REQUEST_IS_DRAFT: false
CONTENT_COMPARISON: true
REVIEWERS: '["boozook"]'

0 comments on commit 6ab6ef9

Please sign in to comment.