Skip to content

Commit

Permalink
Minimal shared rust/python/flatc actions we can reuse in other places (
Browse files Browse the repository at this point in the history
…#1)

Co-authored-by: Robert Kruszewski <github@robertk.io>
  • Loading branch information
AdamGS and robert3005 authored Oct 2, 2024
1 parent b35d21e commit 46996d4
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/actions/lint-proto/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ runs:
using: "docker"
image: "docker://yoheimuta/protolint:0.50.5"
args:
- ${{ inputs.working-directory }}
- ${{ inputs.working-directory }}
16 changes: 16 additions & 0 deletions .github/actions/setup-flatc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Setup Flatc
description: Install the flatbuffers compiler

runs:
using: "composite"
steps:
- name: Download flatc
shell: bash
run: |
curl -sL https://github.com/google/flatbuffers/releases/download/v24.3.25/Linux.flatc.binary.clang++-15.zip > ${{ runner.temp }}/flatc.zip
unzip ${{ runner.temp }}/flatc.zip -d ${{ runner.temp }}/flatc
echo "PATH=${{ runner.temp }}/flatc:$PATH" >> $GITHUB_ENV
- name: Export Path
shell: bash
run: echo "PATH=$PATH" >> $GITHUB_ENV
46 changes: 46 additions & 0 deletions .github/actions/setup-python/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Setup Rust"
description: "Toolchain setup and Initial compilation"
inputs:
rye-version:
description: "Rye version to use"
required: true
default: "0.41.0"

runs:
using: "composite"
steps:
- name: Rye Cache
id: rye-cache
uses: actions/cache@v4
with:
path: ~/.rye
key: "rye-${{ runner.os }}-${{ inputs.rye-version }}"

- name: Rye Install
shell: bash
run: curl -sSf https://rye.astral.sh/get | bash
if: steps.rye-cache.outputs.cache-hit != 'true'
env:
RYE_VERSION: "${{ inputs.rye-version }}"
RYE_INSTALL_OPTION: "--yes"

- name: Rye Shims
shell: bash
run: echo "~/.rye/shims" >> $GITHUB_PATH

- name: Venv Cache
id: venv-cache
uses: actions/cache@v4
with:
path: .venv
key: "venv-${{ runner.os }}-${{ hashFiles('requirements**.lock') }}"

- name: Rye Sync
shell: bash
# --no-lock prevents resolution of the lock file. The locks are still respected.
# We always run `rye sync` even if the cache fetch was successful since it builds our Rust extensions for us.
run: rye sync --no-lock

- name: Export Path
shell: bash
run: echo "PATH=$PATH" >> $GITHUB_ENV
40 changes: 40 additions & 0 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Setup Rust
description: Sets up Rust and relevant toolchain components

inputs:
components:
description: Comma-separated list of components to be additionally installed for a new toolchain
required: false
default: clippy, rustfmt

runs:
using: "composite"
steps:
- name: Rust Version
id: rust-version
shell: bash
run: echo "version=$(cat rust-toolchain.toml | grep channel | awk -F'\"' '{print $2}')" >> $GITHUB_OUTPUT

- name: Rust Toolchain
id: rust-toolchain
uses: dtolnay/rust-toolchain@master
if: steps.rustup-cache.outputs.cache-hit != 'true'
with:
toolchain: "${{ steps.rust-version.outputs.version }}"
components: ${{ inputs.components }}

- name: Rust Dependency Cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref_name == 'develop' }}
shared-key: "shared" # To allow reuse across jobs

- name: Rust Compile Cache
uses: mozilla-actions/sccache-action@v0.0.6

- name: Rust Compile Cache Config
shell: bash
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
.vscode/

0 comments on commit 46996d4

Please sign in to comment.