Skip to content

Commit

Permalink
Merge pull request #2 from Starry-OS/feat_pr
Browse files Browse the repository at this point in the history
chore: add tools for commit patch
  • Loading branch information
Azure-stars authored May 17, 2024
2 parents 94bda5a + b438949 commit c55195d
Show file tree
Hide file tree
Showing 8 changed files with 331 additions and 16 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@ on:
workflow_call:
inputs:
TopTestDirectory:
description: 'The directory where the main repository will be placed'
required: true
type: string
CallerPackage:
description: 'The package to call the workflow'
required: true
type: string
CallerRepository:
description: 'The repository to call the workflow'
required: true
type: string
CallerCommit:
description: 'The commit of the repository to call the workflow'
required: true
type: string


jobs:
prepare_for_external_test:
Expand Down Expand Up @@ -89,8 +101,7 @@ jobs:
if: github.repository != 'Starry-OS/Starry'
run: |
git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }}
mkdir .github/workflows/actions
mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-musl .github/workflows/actions/setup-musl
sh ${{ env.WORKING_DIRECTORY }}/scripts/test/external_test.sh ${{ inputs.CallerPackage }} ${{ inputs.CallerRepository }} ${{ inputs.CallerCommit }}
- name: Build helloworld
working-directory: ${{ env.WORKING_DIRECTORY }}
run: make ARCH=${{ matrix.arch }} A=apps/helloworld
Expand Down Expand Up @@ -187,8 +198,7 @@ jobs:
if: github.repository != 'Starry-OS/Starry'
run: |
git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }}
mkdir .github/workflows/actions
mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-musl .github/workflows/actions/setup-musl
sh ${{ env.WORKING_DIRECTORY }}/scripts/test/external_test.sh ${{ inputs.CallerPackage }} ${{ inputs.CallerRepository }} ${{ inputs.CallerCommit }}
- uses: ./.github/workflows/actions/setup-musl
with:
arch: x86_64
Expand Down Expand Up @@ -235,7 +245,9 @@ jobs:
toolchain: ${{ matrix.rust-toolchain }}
- name: Clone Top Repository
if: github.repository != 'Starry-OS/Starry'
run: git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }}
run: |
git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }}
sh ${{ env.WORKING_DIRECTORY }}/scripts/test/external_test.sh ${{ inputs.CallerPackage }} ${{ inputs.CallerRepository }} ${{ inputs.CallerCommit }}
- name: Build helloworld
working-directory: ${{ env.WORKING_DIRECTORY }}
run: cargo build -p arceos-helloworld
Expand Down Expand Up @@ -299,7 +311,9 @@ jobs:
- run: cargo install cargo-binutils
- name: Clone Top Repository
if: github.repository != 'Starry-OS/Starry'
run: git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }}
run: |
git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }}
sh ${{ env.WORKING_DIRECTORY }}/scripts/test/external_test.sh ${{ inputs.CallerPackage }} ${{ inputs.CallerRepository }} ${{ inputs.CallerCommit }}
- name: Bulld monolithic-userboot
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
Expand Down
25 changes: 16 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ on:
workflow_call:
inputs:
TopTestDirectory:
description: 'The directory where the main repository will be placed'
required: true
type: string
CallerPackage:
description: 'The package to call the workflow'
required: true
type: string
CallerRepository:
description: 'The repository to call the workflow'
required: true
type: string
CallerCommit:
description: 'The commit of the repository to call the workflow'
required: true
type: string

Expand Down Expand Up @@ -51,9 +64,7 @@ jobs:
if: github.repository != 'Starry-OS/Starry'
run: |
git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }}
mkdir .github/workflows/actions
mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-musl .github/workflows/actions/setup-musl
mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-qemu .github/workflows/actions/setup-qemu
sh ${{ env.WORKING_DIRECTORY }}/scripts/test/external_test.sh ${{ inputs.CallerPackage }} ${{ inputs.CallerRepository }} ${{ inputs.CallerCommit }}
- uses: ./.github/workflows/actions/setup-qemu
with:
qemu-version: ${{ env.qemu-version }}
Expand Down Expand Up @@ -88,9 +99,7 @@ jobs:
if: github.repository != 'Starry-OS/Starry'
run: |
git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }}
mkdir .github/workflows/actions
mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-musl .github/workflows/actions/setup-musl
mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-qemu .github/workflows/actions/setup-qemu
sh ${{ env.WORKING_DIRECTORY }}/scripts/test/external_test.sh ${{ inputs.CallerPackage }} ${{ inputs.CallerRepository }} ${{ inputs.CallerCommit }}
- uses: ./.github/workflows/actions/setup-qemu
with:
qemu-version: ${{ env.qemu-version }}
Expand Down Expand Up @@ -124,9 +133,7 @@ jobs:
if: github.repository != 'Starry-OS/Starry'
run: |
git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }}
mkdir .github/workflows/actions
mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-musl .github/workflows/actions/setup-musl
mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-qemu .github/workflows/actions/setup-qemu
sh ${{ env.WORKING_DIRECTORY }}/scripts/test/external_test.sh ${{ inputs.CallerPackage }} ${{ inputs.CallerRepository }} ${{ inputs.CallerCommit }}
- uses: ./.github/workflows/actions/setup-qemu
with:
qemu-version: ${{ env.qemu-version }}
Expand Down
22 changes: 22 additions & 0 deletions scripts/test/external_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# The directory of the main repo
WORK_DIR=$1

PATCH_TOOL_DIR=$WORK_DIR/tools/patch_tool

# The package which needs to be patched
# It always be the package which triggers the test
PATCH_PACKAGE=$2

# The URL of the patch points to
PATCH_TARGET_URL=$3

# The commit hash of the patch
PATCH_COMMIT_HASH=$4

# To run the main repo actions
mkdir .github/workflows/actions
mv $WORK_DIR/.github/workflows/actions/* .github/workflows/actions

# To do the patch for current commit
cd $PATCH_TOOL_DIR
cargo run -- $WORK_DIR $PATCH_PACKAGE $PATCH_TARGET_URL $PATCH_COMMIT_HASH
1 change: 1 addition & 0 deletions tools/patch_tool/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
153 changes: 153 additions & 0 deletions tools/patch_tool/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions tools/patch_tool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[dependencies]
anyhow = "1.0"
toml = "0.8"

[dependencies.serde]
features = ["derive"]
version = "1.0"

[package]
edition = "2021"
name = "patch_tool"
version = "0.1.0"

[workspace]
12 changes: 12 additions & 0 deletions tools/patch_tool/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mod patch;
#[macro_use]
extern crate anyhow;
fn main() {
let args: Vec<String> = std::env::args().collect();
let cargo_path = &args[1];
let patch_name = &args[2];
// 默认服务端是 github,后续可能需要根据默认参数来传递
let patch_repo_name = &args[3];
let commit = &args[4];
patch::do_patch(cargo_path, patch_name, patch_repo_name, commit).unwrap();
}
Loading

0 comments on commit c55195d

Please sign in to comment.