Skip to content

Commit

Permalink
Separate code generation in jobs
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Gisondi <[email protected]>
  • Loading branch information
harlem88 committed Sep 29, 2023
1 parent a61f059 commit 65fd4f1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
38 changes: 33 additions & 5 deletions .github/workflows/code-generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,21 @@ jobs:
- name: Generate Python code
run: python3 ./protoc.py "./../grpc/grpc_python_plugin"
working-directory: ./python

- name: Upload Python code
uses: actions/upload-artifact@v3
with:
name: python
path: ./python

rust-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install protoc
run: |
curl -LO $PB_REL/download/v24.3/protoc-24.3-linux-x86_64.zip
unzip protoc-24.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -85,13 +99,27 @@ jobs:
- name: Generate Rust code with cargo build
run: cargo build
working-directory: ./rust
- name: Commit the generated code
if: github.event_name == 'push'
run: |
- name: Upload Rust code
uses: actions/upload-artifact@v3
with:
name: rust
path: ./rust

commit_and_push_code:
name: Display results
needs: [python_build, rust_build]
runs-on: ubuntu-latest
steps:
if: github.event_name == 'push'
- uses: actions/checkout@v4
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
- name: Commit the generated code
run: |
git config user.name github-actions
git config user.email [email protected]
git add ./python
git diff --staged --quiet || git commit -s -m "Generated Python code"
git add ./rust/astarte-message-hub-proto/src/astarteplatform.msghub.rs
git diff --staged --quiet || git commit -s -m "Generated Rust code"
git push
git push
3 changes: 2 additions & 1 deletion .github/workflows/rust-check-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ jobs:
run: rustup component add rustfmt
- name: Check formatting
run: rustfmt --check ./build.rs
working-directory: ./rust
working-directory: ./rust

0 comments on commit 65fd4f1

Please sign in to comment.