Skip to content

Only run lalrpop generation on ubuntu-latest #4132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
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
100 changes: 24 additions & 76 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,18 @@ jobs:
env:
RUST_BACKTRACE: full
name: Run rust tests
needs: lalrpop
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false
steps:
# for windows, always checkout files with their original lf line endings
- run: git config --global core.autocrlf false; git config --global core.eol lf
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- uses: actions/cache@v3
with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" }
- run: cargo install lalrpop@0.19.8
- uses: dtolnay/rust-toolchain@stable
- name: Set up the Windows environment
shell: bash
Expand Down Expand Up @@ -153,15 +152,12 @@ jobs:
exotic_targets:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
name: Ensure compilation on various targets
needs: lalrpop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- uses: actions/cache@v3
with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" }
- run: cargo install lalrpop@0.19.8

- uses: dtolnay/rust-toolchain@stable
with:
Expand Down Expand Up @@ -217,7 +213,6 @@ jobs:

snippets_cpython:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
needs: lalrpop
env:
RUST_BACKTRACE: full
name: Run snippets and cpython tests
Expand All @@ -227,12 +222,11 @@ jobs:
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false
steps:
- run: git config --global core.autocrlf false; git config --global core.eol lf
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- uses: actions/cache@v3
with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" }
- run: cargo install lalrpop@0.19.8

- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v2
Expand Down Expand Up @@ -281,51 +275,14 @@ jobs:
run: |
mkdir site-packages
target/release/rustpython --install-pip ensurepip --user

lalrpop:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
name: Generate parser with lalrpop
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- name: Check if cached generated parser exists
id: generated_parser
uses: andstor/file-existence-action@v1
with:
files: "compiler/parser/python.rs"
- if: runner.os == 'Windows'
name: Force python.lalrpop to be lf # actions@checkout ignore .gitattributes
run: |
set file compiler/parser/python.lalrpop; ((Get-Content $file) -join "`n") + "`n" | Set-Content -NoNewline $file
- name: Install lalrpop
if: steps.generated_parser.outputs.files_exists == 'false'
uses: baptiste0928/cargo-install@v1
with:
crate: lalrpop
version: "0.19.8"
- name: Run lalrpop
if: steps.generated_parser.outputs.files_exists == 'false'
run: lalrpop compiler/parser/python.lalrpop

lint:
name: Check Rust code with rustfmt and clippy
needs: lalrpop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- uses: actions/cache@v3
with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" }
- run: cargo install lalrpop@0.19.8
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
Expand Down Expand Up @@ -355,15 +312,12 @@ jobs:
miri:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
name: Run tests under miri
needs: lalrpop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- uses: actions/cache@v3
with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" }
- run: cargo install lalrpop@0.19.8
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
Expand All @@ -377,15 +331,12 @@ jobs:
wasm:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
name: Check the WASM package and demo
needs: lalrpop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- uses: actions/cache@v3
with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" }
- run: cargo install lalrpop@0.19.8
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v1
- name: install wasm-pack
Expand Down Expand Up @@ -426,15 +377,12 @@ jobs:
wasm-wasi:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
name: Run snippets and cpython tests on wasm-wasi
needs: lalrpop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- uses: actions/cache@v3
with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" }
- run: cargo install lalrpop@0.19.8
- uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-wasi
Expand Down
68 changes: 12 additions & 56 deletions .github/workflows/cron-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ env:
jobs:
codecov:
name: Collect code coverage data
needs: lalrpop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- uses: actions/cache@v3
with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" }
- run: cargo install lalrpop@0.19.8
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
Expand Down Expand Up @@ -62,15 +59,12 @@ jobs:

testdata:
name: Collect regression test data
needs: lalrpop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- uses: actions/cache@v3
with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" }
- run: cargo install lalrpop@0.19.8
- uses: dtolnay/rust-toolchain@stable
- name: build rustpython
run: cargo build --release --verbose
Expand All @@ -97,15 +91,12 @@ jobs:

whatsleft:
name: Collect what is left data
needs: lalrpop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- uses: actions/cache@v3
with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" }
- run: cargo install lalrpop@0.19.8
- uses: dtolnay/rust-toolchain@stable
- name: build rustpython
run: cargo build --release --verbose
Expand Down Expand Up @@ -135,15 +126,12 @@ jobs:

benchmark:
name: Collect benchmark data
needs: lalrpop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- uses: actions/cache@v3
with: { path: "~/.cargo/bin/lalrpop\n~/.cargo/.crates.toml", key: "lalrpop-${{ runner.os }}" }
- run: cargo install lalrpop@0.19.8
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -183,35 +171,3 @@ jobs:
if git -c user.name="Github Actions" -c user.email="actions@github.com" commit -m "Update benchmark results"; then
git push
fi

lalrpop:
name: Generate parser with lalrpop
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Cache generated parser
uses: actions/cache@v2
with:
path: compiler/parser/python.rs
key: lalrpop-${{ hashFiles('compiler/parser/python.lalrpop') }}
- name: Check if cached generated parser exists
id: generated_parser
uses: andstor/file-existence-action@v1
with:
files: "compiler/parser/python.rs"
- if: runner.os == 'Windows'
name: Force python.lalrpop to be lf # actions@checkout ignore .gitattributes
run: |
set file compiler/parser/python.lalrpop; ((Get-Content $file) -join "`n") + "`n" | Set-Content -NoNewline $file
- name: Install lalrpop
if: steps.generated_parser.outputs.files_exists == 'false'
uses: baptiste0928/cargo-install@v1
with:
crate: lalrpop
version: "0.19.8"
- name: Run lalrpop
if: steps.generated_parser.outputs.files_exists == 'false'
run: lalrpop compiler/parser/python.lalrpop
4 changes: 0 additions & 4 deletions Lib/test/test_difflib.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,6 @@ def test_html_diff(self):
with open(findfile('test_difflib_expect.html')) as fp:
self.assertEqual(actual, fp.read())

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_html_diff = unittest.expectedFailure(test_html_diff)

def test_recursion_limit(self):
# Check if the problem described in patch #1413711 exists.
limit = sys.getrecursionlimit()
Expand Down
4 changes: 0 additions & 4 deletions Lib/test/test_imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ def test_issue1267(self):
self.assertEqual(fp.readline(),
'"""Tokenization help for Python programs.\n')

# TODO: RUSTPYTHON
if sys.platform == 'win32':
test_issue1267 = unittest.expectedFailure(test_issue1267)

def test_issue3594(self):
temp_mod_name = 'test_imp_helper'
sys.path.insert(0, '.')
Expand Down
26 changes: 20 additions & 6 deletions compiler/parser/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,30 @@ fn try_lalrpop(source: &str, target: &str) -> anyhow::Result<()> {
};

#[cfg(feature = "lalrpop")]
lalrpop::process_root().unwrap_or_else(|e| {
println!("cargo:warning={_message}");
panic!("running lalrpop failed. {e:?}");
});
{
lalrpop::process_root().unwrap_or_else(|e| {
println!("cargo:warning={_message}");
panic!("running lalrpop failed. {e:?}");
});
Ok(())
}

#[cfg(not(feature = "lalrpop"))]
{
println!("cargo:warning=try: cargo build --manifest-path=compiler/parser/Cargo.toml --features=lalrpop");
match std::process::Command::new("lalrpop").arg(source).status() {
Ok(status) => {
if status.success() {
Ok(())
} else {
Err(anyhow::anyhow!("running lalrpop failed: {status}"))
}
}
Err(_) => panic!(
"lalrpop not installed. try: cargo build \
--manifest-path=compiler/parser/Cargo.toml --features=lalrpop"
),
}
}
Ok(())
}

fn sha_equal(expected_sha3_str: &str, actual_sha3: &[u8; 32]) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions compiler/parser/python.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ SimpleStatement: ast::Suite = {
let mut statements = vec![s1];
statements.extend(s2.into_iter().map(|e| e.1));
statements
}
},
};

SmallStatement: ast::Stmt = {
Expand Down Expand Up @@ -138,7 +138,7 @@ ExpressionStatement: ast::Stmt = {
};

AssignSuffix: ast::Expr = {
"=" <e:TestListOrYieldExpr> => e
"=" <e:TestListOrYieldExpr> => e,
};

TestListOrYieldExpr: ast::Expr = {
Expand Down