Skip to content

Commit

Permalink
Merge pull request #146 from EATSTEAK/dev
Browse files Browse the repository at this point in the history
[ci] iOS 배포 워크플로 등록
  • Loading branch information
EATSTEAK authored Dec 21, 2024
2 parents 47b323e + 20e1ead commit 3b58c7e
Show file tree
Hide file tree
Showing 16 changed files with 320 additions and 55 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build & Test
on:
workflow_dispatch:
pull_request:
branches: [ "main", "dev" ]
branches: [ "dev" ]
schedule:
- cron: "23 3 * * *"
env:
Expand All @@ -12,6 +12,9 @@ jobs:
build:
runs-on: ubuntu-latest
environment: testing
concurrency:
group: testing
cancel-in-progress: true
env:
SSO_ID: ${{ vars.SSO_ID }}
SSO_PASSWORD: ${{ secrets.SSO_PASSWORD }}
Expand All @@ -21,6 +24,10 @@ jobs:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Retrieve cache
uses: Leafwing-Studios/cargo-cache@v2
with:
cache-group: build
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/dry-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ on:
env:
CARGO_TERM_COLOR: always
jobs:
build:
dry-run:
runs-on: ubuntu-latest
environment: testing
concurrency:
group: testing
cancel-in-progress: true
env:
SSO_ID: ${{ vars.SSO_ID }}
SSO_PASSWORD: ${{ secrets.SSO_PASSWORD }}
Expand All @@ -19,6 +22,8 @@ jobs:
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Retrieve cache
uses: Leafwing-Studios/cargo-cache@v2
- name: Publish dry-run
run: cargo publish -p rusaint --dry-run --verbose
- name: Run tests
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint

on:
workflow_dispatch:
pull_request:
branches: [ "main", "dev" ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy, rustfmt
- name: Retrieve cache
uses: Leafwing-Studios/cargo-cache@v2
with:
cache-group: build
- name: Check rustfmt
run: cargo +nightly fmt
- name: Check clippy
run: cargo +nightly clippy -- -D warnings
150 changes: 150 additions & 0 deletions .github/workflows/release-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Release (iOS)

on:
push:
branches: [ dev ]
paths:
- './Cargo.toml'
workflow_dispatch:
permissions:
actions: write
jobs:
release-ios:
runs-on: macos-latest
steps:
- name: Checkout Cargo.toml to check version
uses: actions/checkout@v4
with:
token: ${{ secrets.IOS_GITHUB_TOKEN }}
sparse-checkout: |
Cargo.toml
sparse-checkout-cone-mode: false
- name: Get rusaint version
id: current_version
uses: mikefarah/yq@v4
with:
cmd: yq '.workspace.package.version | "v" + .' Cargo.toml
- name: Fetch latest release tag
id: latest_release
run: |
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.IOS_GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/EATSTEAK/rusaint/releases \
| jq '.[0].tag_name | "result=" + .' \
| tr -d '"' >> $GITHUB_OUTPUT
- name: Cancel workflow if version is not updated
if: steps.current_version.outputs.result == steps.latest_release.outputs.result
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
- name: Checkout the repository
uses: actions/checkout@v4
with:
token: ${{ secrets.IOS_GITHUB_TOKEN }}
submodules: 'recursive'
- name: Attach HEAD in submodule
working-directory: languages/swift/Rusaint
run: git switch main
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: 'aarch64-apple-ios, x86_64-apple-ios, aarch64-apple-ios-sim'
- name: Retrieve cache
uses: Leafwing-Studios/cargo-cache@v2
- name: Install the Apple certificate
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.IOS_BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.IOS_P12_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/signing.keychain-db
# import certificate from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
- name: Build native library
env:
IPHONEOS_DEPLOYMENT_TARGET: ${{ vars.IOS_DEPLOYMENT_TARGET || '14.0' }}
RUSTFLAGS: '-C link-arg=-Wl,-application_extension'
run: |
mkdir $RUNNER_TEMP/target
CARGO_TARGET_DIR=$RUNNER_TEMP/target
cargo build --package rusaint-ffi --target aarch64-apple-ios-sim --release
cargo build --package rusaint-ffi --target aarch64-apple-ios --release
cargo build --package rusaint-ffi --target x86_64-apple-ios --release
- name: Create universal libraries for simulator
run: |
mkdir -p $RUNNER_TEMP/target/universal-ios-sim/release
lipo -create \
$RUNNER_TEMP/target/aarch64-apple-ios-sim/release/librusaint_ffi.a \
$RUNNER_TEMP/target/x86_64-apple-ios/release/librusaint_ffi.a \
-output $RUNNER_TEMP/target/universal-ios-sim/release/librusaint_ffi.a
- name: Generate swift bindings
run: |
cargo run -p uniffi-bindgen generate \
$RUNNER_TEMP/target/aarch64-apple-ios/release/librusaint_ffi.dylib \
--library \
--language swift \
--no-format \
--out-dir $RUNNER_TEMP/bindings
- name: Move generated swift bindgs
run: mv $RUNNER_TEMP/bindings/*.swift ./languages/swift/Rusaint/Sources/Rusaint/
- name: Massage the generated files to fit xcframework
run: |
mkdir $RUNNER_TEMP/Headers
mv $RUNNER_TEMP/bindings/*.h $RUNNER_TEMP/Headers/
cat $RUNNER_TEMP/bindings/*.modulemap > $RUNNER_TEMP/Headers/module.modulemap
- name: Create xcframework
run: |
rm -r ./languages/swift/Rusaint/Artifacts/RusaintFFI.xcframework
xcodebuild -create-xcframework \
-library $RUNNER_TEMP/target/aarch64-apple-ios/release/librusaint_ffi.a \
-headers $RUNNER_TEMP/Headers \
-library $RUNNER_TEMP/target/universal-ios-sim/release/librusaint_ffi.a \
-headers $RUNNER_TEMP/Headers \
-output ./languages/swift/Rusaint/Artifacts/RusaintFFI.xcframework
- name: Sign xcframework
env:
KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEYCHAIN_PASSWORD }}
run: |
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $RUNNER_TEMP/signing.keychain-db
codesign --timestam-p -s "Apple Development" ./languages/swift/Rusaint/Artifacts/RusaintFFI.xcframework
- name: Push to submodule
working-directory: languages/swift/Rusaint
run: |
git config user.name "GitHub Actions"
git config user.email ""
git add .
git commit -m "release: ${{ steps.current_version.outputs.result }}"
git push
- name: Commit submodule in main repository
run: |
git config user.name "GitHub Actions"
git config user.email ""
git add languages/swift/Rusaint
git commit -m "release(ios): ${{ steps.current_version.outputs.result }}"
git push
- name: Create release
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.IOS_GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/EATSTEAK/rusaint-ios/releases \
-d '{"tag_name":"${{ steps.current_version.outputs.result }}","name":"${{ steps.current_version.outputs.result }}"}'
40 changes: 37 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,47 @@ on:
env:
CARGO_TERM_COLOR: always
jobs:
build:
release:
runs-on: ubuntu-latest
environment: testing
steps:
- name: Checkout Cargo.toml to check version
uses: actions/checkout@v4
with:
token: ${{ secrets.IOS_GITHUB_TOKEN }}
sparse-checkout: |
Cargo.toml
sparse-checkout-cone-mode: false
- name: Get rusaint version
id: current_version
uses: mikefarah/yq@v4
with:
cmd: yq '.workspace.package.version | "v" + .' Cargo.toml
- name: Fetch latest release tag
id: latest_release
run: |
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.IOS_GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/EATSTEAK/rusaint/releases \
| jq '.[0].tag_name | "result=" + .' \
| tr -d '"' >> $GITHUB_OUTPUT
- name: Cancel workflow if version is not updated
if: steps.current_version.outputs.result == steps.latest_release.outputs.result
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: 'armv7-linux-androideabi, i686-linux-android, aarch64-linux-android, x86_64-linux-android'
- name: Retrieve cache
uses: Leafwing-Studios/cargo-cache@v2
with:
- name: Setup Java
uses: actions/setup-java@v4
with:
Expand All @@ -27,7 +58,10 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup Android NDK
run: 'sdkmanager "ndk;27.2.12479018"'
uses: nttld/setup-ndk@v1
with:
ndk-version: r27c
link-to-sdk: true
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
Expand Down
2 changes: 1 addition & 1 deletion languages/swift/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lipo -create ../../target/aarch64-apple-ios-sim/release/librusaint_ffi.a \

# Generate swift bindings
cargo run -p uniffi-bindgen generate \
../../target/aarch64-apple-ios-sim/release/librusaint_ffi.dylib \
../../target/aarch64-apple-ios/release/librusaint_ffi.dylib \
--library \
--language swift \
--no-format \
Expand Down
13 changes: 9 additions & 4 deletions packages/rusaint/src/application/course_grades/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use self::model::{ClassGrade, CourseType, GradeSummary, SemesterGrade};
use super::{USaintApplication, USaintClient};
use crate::application::utils::sap_table::try_table_into_with_scroll;
use crate::webdynpro::client::body::Body;
use crate::webdynpro::command::WebDynproCommandExecutor;
use crate::webdynpro::element::complex::sap_table::cell::SapTableCellWrapper;
Expand Down Expand Up @@ -295,13 +296,17 @@ impl<'a> CourseGradesApplication {
self.close_popups().await?;
let parser = ElementParser::new(self.client.body());
self.select_course(&parser, course_type).await?;
self.read_semesters()
self.read_semesters().await
}

fn read_semesters(&self) -> Result<Vec<SemesterGrade>, RusaintError> {
async fn read_semesters(&mut self) -> Result<Vec<SemesterGrade>, RusaintError> {
let parser = ElementParser::new(self.client.body());
let table = parser.read(SapTableBodyCommand::new(Self::GRADES_SUMMARY_TABLE))?;
let ret = table.try_table_into::<SemesterGrade>(&parser)?;
let ret = try_table_into_with_scroll::<SemesterGrade>(
&mut self.client,
parser,
Self::GRADES_SUMMARY_TABLE,
)
.await?;
Ok(ret)
}

Expand Down
5 changes: 4 additions & 1 deletion packages/rusaint/src/application/course_schedule/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::{USaintApplication, USaintClient};
use crate::application::utils::sap_table::try_table_into_with_scroll;
use crate::webdynpro::command::WebDynproCommandExecutor;
use crate::webdynpro::element::parser::ElementParser;
use crate::{
Expand Down Expand Up @@ -128,7 +129,9 @@ impl<'a> CourseScheduleApplication {
}
}
}
let lectures = table.try_table_into::<Lecture>(&parser)?;
let lectures =
try_table_into_with_scroll::<Lecture>(&mut self.client, parser, Self::MAIN_TABLE)
.await?;
Ok(lectures.into_iter())
}

Expand Down
Loading

0 comments on commit 3b58c7e

Please sign in to comment.