Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 88 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,81 @@ env:
PYTHON_VERSION: "3.13.1"

jobs:
auto_format_pr:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: read
steps:
- name: Checkout PR branch
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ github.token }}
fetch-depth: 0

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Run cargo fmt
run: cargo fmt --all

- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: git add
run: git add -u

- name: git commit
id: git-commit
run: git commit -m "run `cargo fmt --all`"
continue-on-error: true # Will fail if nothing to commit

- name: Comment on PR
if: ${{ steps.git-commit.outcome == 'success' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ github.event.pull_request.number }}
message: |
**Code has been automatically formatted**

The code in this PR has been formatted using `cargo fmt --all`.

You may need to pull the latest changes before pushing again:
```bash
git pull origin ${{ github.event.pull_request.head.ref }}
```

**Triggered by commit:** `${{ github.event.pull_request.head.sha }}`
**Last formatted:** ${{ github.event.pull_request.updated_at }}
**Run**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

- name: git push
run: git push origin HEAD:${{ env.HEAD_REF }}
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
if: steps.git-commit.outcome == 'success'

# This step is not really needed as the earlier push should cancel this run anyways.
# But we are making sure that we abort if we had badly formatted files.
- name: Exit if changed
run: exit 1
if: ${{ steps.git-commit.outcome == 'success' }}

rust_tests:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
env:
RUST_BACKTRACE: full
name: Run rust tests
needs:
- auto_format_pr
runs-on: ${{ matrix.os }}
timeout-minutes: ${{ contains(matrix.os, 'windows') && 45 || 35 }}
strategy:
Expand Down Expand Up @@ -173,8 +243,10 @@ jobs:
if: runner.os == 'macOS'

exotic_targets:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
name: Ensure compilation on various targets
needs:
- auto_format_pr
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand Down Expand Up @@ -234,10 +306,12 @@ jobs:
# args: --ignore-rust-version

snippets_cpython:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
env:
RUST_BACKTRACE: full
name: Run snippets and cpython tests
needs:
- auto_format_pr
runs-on: ${{ matrix.os }}
timeout-minutes: ${{ contains(matrix.os, 'windows') && 45 || 35 }}
strategy:
Expand Down Expand Up @@ -308,6 +382,8 @@ jobs:

lint:
name: Check Rust code with clippy
needs:
- auto_format_pr
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
Expand Down Expand Up @@ -342,8 +418,10 @@ jobs:
incremental_files_only: true

miri:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
name: Run tests under miri
needs:
- auto_format_pr
runs-on: ubuntu-latest
timeout-minutes: 30
env:
Expand All @@ -366,8 +444,10 @@ jobs:
MIRIFLAGS: '-Zmiri-ignore-leaks'

wasm:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
name: Check the WASM package and demo
needs:
- auto_format_pr
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand Down Expand Up @@ -427,8 +507,10 @@ jobs:
PUBLISH_BRANCH: master

wasm-wasi:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
if: ${{ !cancelled() && !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
name: Run snippets and cpython tests on wasm-wasi
needs:
- auto_format_pr
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand Down
99 changes: 0 additions & 99 deletions .github/workflows/pr-auto-commit.yaml

This file was deleted.

9 changes: 6 additions & 3 deletions crates/vm/src/stdlib/ast/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ impl Node for ruff::ConversionFlag {
) -> PyResult<Self> {
i32::try_from_object(vm, object)?
.to_u32()
.and_then(bytecode::ConversionFlag::from_op_arg)
.and_then(
bytecode::ConversionFlag::from_op_arg)
.map(|flag| match flag {
bytecode::ConversionFlag::None => Self::None,
bytecode::ConversionFlag::Str => Self::Str,
bytecode::ConversionFlag::None =>
Self::None,
bytecode::ConversionFlag::Str =>
Self::Str,
bytecode::ConversionFlag::Ascii => Self::Ascii,
bytecode::ConversionFlag::Repr => Self::Repr,
})
Expand Down
Loading