Skip to content

Commit

Permalink
Updates to Rust workflow (#390)
Browse files Browse the repository at this point in the history
* update rust workflow

* pre-commit update

* rename build job and add test run

* remove cargo audit

* unify all actions
  • Loading branch information
Esgrove authored Mar 18, 2024
1 parent 62d9b25 commit 78d9fb4
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 103 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
name: Python black

# Run either when pushing directly to main/master or in a PR targeting main/master
on:
push:
branches:
- master
- main
paths:
- "**.py"
- ".github/workflows/black.yml"
- "**.py"
pull_request:
branches:
- master
- main
paths:
- "**.py"
- ".github/workflows/black.yml"
- "**.py"

# Cancel previous runs for PRs but not pushes to main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

# https://github.com/psf/black
jobs:
Expand Down
65 changes: 0 additions & 65 deletions .github/workflows/cargo.yml

This file was deleted.

17 changes: 12 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Go build
name: Go

# Run either when pushing directly to main/master or in a PR targeting main/master
on:
push:
branches:
Expand All @@ -16,18 +15,26 @@ on:
- master
- main

# Cancel previous runs for PRs but not pushes to main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./go

steps:
- uses: actions/checkout@v4
- name: Check out repository
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21.x"
go-version: "1.22.x"
cache-dependency-path: go/go.sum

- name: Install dependencies
Expand All @@ -36,5 +43,5 @@ jobs:
- name: Build
run: go build -v ./...

- name: Test with the Go CLI
- name: Run tests
run: go test
9 changes: 5 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: Integration Tests

# Run either when pushing directly to main/master or in a PR targeting main/master
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

permissions:
id-token: write
contents: read

# Cancel previous runs for PRs but not pushes to main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
name: Python isort

# Run either when pushing directly to main/master or in a PR targeting main/master
on:
push:
branches:
- master
- main
paths:
- "**.py"
- ".github/workflows/isort.yml"
- "**.py"
pull_request:
branches:
- master
- main
paths:
- "**.py"
- ".github/workflows/isort.yml"
- "**.py"

# Cancel previous runs for PRs but not pushes to main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

# https://github.com/marketplace/actions/python-isort
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Check out source repository
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python environment
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
name: Python pip

# Run either when pushing directly to main/master or in a PR targeting main/master
on:
push:
branches:
- master
- main
paths:
- "python/requirements.txt"
- ".github/workflows/pip.yml"
- "python/requirements.txt"
pull_request:
branches:
- master
- main
paths:
- "python/requirements.txt"
- ".github/workflows/pip.yml"
- "python/requirements.txt"

# Cancel previous runs for PRs but not pushes to main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true


# https://github.com/py-actions/py-dependency-install
jobs:
dependencies:
runs-on: ubuntu-latest
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ on:
- master
- main
paths:
- "**.py"
- ".github/workflows/ruff.yml"
- "**.py"
pull_request:
branches:
- master
- main
paths:
- "**.py"
- ".github/workflows/ruff.yml"
- "**.py"

# Cancel previous runs for PRs but not pushes to main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

# https://github.com/chartboost/ruff-action
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Check out source repository
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python environment
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Rust

on:
push:
branches:
- master
- main
paths:
- ".github/workflows/rust.yml"
- "**.rs"
- "rust/Cargo.lock"
- "rust/Cargo.toml"
pull_request:
paths:
- ".github/workflows/rust.yml"
- "**.rs"
- "rust/Cargo.lock"
- "rust/Cargo.toml"

# Cancel previous runs for PRs but not pushes to main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./rust

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable

- uses: Swatinem/rust-cache@v2.7.3
with:
workspaces: ./rust -> target

- name: Set up cargo cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Build
run: cargo build

- name: Run tests
run: cargo test --no-fail-fast

lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./rust

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy

- name: Cache dependencies
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Check formatting
run: cargo fmt --check --verbose

- name: Lint
run: cargo clippy -- -Dwarnings
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.2
rev: v0.3.3
hooks:
- id: ruff
name: python ruff
files: ^python/
args: [--fix, --exit-non-zero-on-fix, --config, python/pyproject.toml]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.2.0
rev: 24.3.0
hooks:
- id: black
name: python black
Expand Down

0 comments on commit 78d9fb4

Please sign in to comment.