Try other

This commit is contained in:
Charlie Marsh 2022-08-29 10:05:37 -04:00
parent e4f6780716
commit 423d1a9966
6 changed files with 183 additions and 289 deletions

View File

@ -1,122 +0,0 @@
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
cargo_build:
name: "cargo build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/cache@v3
env:
cache-name: cache-cargo
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: cargo build --release
cargo_fmt:
name: "cargo fmt"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/cache@v3
env:
cache-name: cache-cargo
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: cargo fmt --check
cargo_clippy:
name: "cargo clippy"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/cache@v3
env:
cache-name: cache-cargo
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: cargo clippy -- -D warnings
cargo_test:
name: "cargo test"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/cache@v3
env:
cache-name: cache-cargo
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: cargo test
maturin_build:
name: "maturin build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install maturin
- uses: actions/cache@v3
env:
cache-name: cache-cargo
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: maturin build -b bin

View File

@ -1,17 +1,26 @@
name: Release
on:
push:
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PACKAGE_NAME: ruff
PYTHON_VERSION: "3.10"
jobs:
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
@ -23,19 +32,19 @@ jobs:
uses: messense/maturin-action@v1
with:
target: x86_64
args: --release --out dist --sdist
args: -i ${{ env.PYTHON_VERSION }} --release --out dist --sdist
maturin-version: "latest"
- name: Install built wheel - x86_64
run: |
pip install ruff --no-index --find-links dist --force-reinstall
python -c "import ruff"
pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
- name: Build wheels - universal2
uses: messense/maturin-action@v1
with:
args: --release --universal2 --out dist
maturin-version: "latest"
- name: Install built wheel - universal2
run: |
pip install ruff --no-index --find-links dist --force-reinstall
python -c "import ruff"
pip install dist/${{ env.PACKAGE_NAME }}-*universal2.whl --force-reinstall
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
@ -48,10 +57,10 @@ jobs:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: ${{ env.PYTHON_VERSION }}
architecture: ${{ matrix.target }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
@ -63,11 +72,12 @@ jobs:
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
args: -i ${{ env.PYTHON_VERSION }} --release --out dist
maturin-version: "latest"
- name: Install built wheel
shell: bash
run: |
pip install ruff --no-index --find-links dist --force-reinstall
python -c "import ruff"
python -m pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
@ -80,154 +90,158 @@ jobs:
matrix:
target: [x86_64, i686]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: x64
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist
- name: Install built wheel
if: matrix.target == 'x86_64'
run: |
pip install ruff --no-index --find-links dist --force-reinstall
python -c "import ruff"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
linux-cross:
runs-on: ubuntu-latest
strategy:
matrix:
target: [aarch64, armv7, s390x, ppc64le, ppc64]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist
- uses: uraimo/run-on-arch-action@v2.0.5
if: matrix.target != 'ppc64'
name: Install built wheel
with:
arch: ${{ matrix.target }}
distro: ubuntu20.04
githubToken: ${{ github.token }}
install: |
apt-get update
apt-get install -y --no-install-recommends python3 python3-pip
pip3 install -U pip
run: |
pip3 install ruff --no-index --find-links dist/ --force-reinstall
python3 -c "import ruff"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
musllinux:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-musl
- i686-unknown-linux-musl
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: x64
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: musllinux_1_2
args: --release --out dist
- name: Install built wheel
if: matrix.target == 'x86_64-unknown-linux-musl'
uses: addnab/docker-run-action@v3
with:
image: alpine:latest
options: -v ${{ github.workspace }}:/io -w /io
run: |
apk add py3-pip
pip3 install -U pip
pip3 install ruff --no-index --find-links /io/dist/ --force-reinstall
python3 -c "import ruff"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
musllinux-cross:
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- target: aarch64-unknown-linux-musl
arch: aarch64
- target: armv7-unknown-linux-musleabihf
arch: armv7
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
manylinux: musllinux_1_2
args: --release --out dist
- uses: uraimo/run-on-arch-action@master
name: Install built wheel
with:
arch: ${{ matrix.platform.arch }}
distro: alpine_latest
githubToken: ${{ github.token }}
install: |
apk add py3-pip
pip3 install -U pip
run: |
pip3 install ruff --no-index --find-links dist/ --force-reinstall
python3 -c "import ruff"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ macos, windows, linux, linux-cross, musllinux, musllinux-cross ]
steps:
- uses: actions/download-artifact@v2
with:
name: wheels
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Publish to PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: -i ${{ env.PYTHON_VERSION }} --release --out dist
maturin-version: "latest"
- name: Install built wheel
if: matrix.target == 'x86_64'
run: |
pip install --upgrade twine
twine upload --skip-existing *
pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
# linux-cross:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# target: [aarch64, armv7]
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# with:
# python-version: ${{ env.PYTHON_VERSION }}
# - name: Build wheels
# uses: messense/maturin-action@v1
# with:
# target: ${{ matrix.target }}
# manylinux: auto
# args: -i ${{ env.PYTHON_VERSION }} --release --out dist
# maturin-version: "latest"
# - uses: uraimo/run-on-arch-action@v2.0.5
# if: matrix.target != 'ppc64'
# name: Install built wheel
# with:
# arch: ${{ matrix.target }}
# distro: ubuntu20.04
# githubToken: ${{ github.token }}
# install: |
# apt-get update
# apt-get install -y --no-install-recommends python3 python3-pip
# pip3 install -U pip
# run: |
# pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall
# - name: Upload wheels
# uses: actions/upload-artifact@v2
# with:
# name: wheels
# path: dist
# musllinux:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# target:
# - x86_64-unknown-linux-musl
# - i686-unknown-linux-musl
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# with:
# python-version: ${{ env.PYTHON_VERSION }}
# architecture: x64
# - name: Build wheels
# uses: messense/maturin-action@v1
# with:
# target: ${{ matrix.target }}
# manylinux: musllinux_1_2
# args: -i ${{ env.PYTHON_VERSION }} --release --out dist
# maturin-version: "latest"
# - name: Install built wheel
# if: matrix.target == 'x86_64-unknown-linux-musl'
# uses: addnab/docker-run-action@v3
# with:
# image: alpine:latest
# options: -v ${{ github.workspace }}:/io -w /io
# run: |
# apk add py3-pip
# pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links /io/dist/ --force-reinstall
# - name: Upload wheels
# uses: actions/upload-artifact@v2
# with:
# name: wheels
# path: dist
#
# musllinux-cross:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# platform:
# - target: aarch64-unknown-linux-musl
# arch: aarch64
# - target: armv7-unknown-linux-musleabihf
# arch: armv7
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# with:
# python-version: ${{ env.PYTHON_VERSION }}
# - name: Build wheels
# uses: messense/maturin-action@v1
# with:
# target: ${{ matrix.platform.target }}
# manylinux: musllinux_1_2
# args: -i ${{ env.PYTHON_VERSION }} --release --out dist
# maturin-version: "latest"
# - uses: uraimo/run-on-arch-action@master
# name: Install built wheel
# with:
# arch: ${{ matrix.platform.arch }}
# distro: alpine_latest
# githubToken: ${{ github.token }}
# install: |
# apk add py3-pip
# run: |
# pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall
# - name: Upload wheels
# uses: actions/upload-artifact@v2
# with:
# name: wheels
# path: dist
# release:
# name: Release
# runs-on: ubuntu-latest
# needs:
# - lint
# - macos
# - windows
# - linux
# - linux-cross
# - musllinux
# - musllinux-cross
# - pypy
# if: ${{ github.ref == 'refs/heads/main' }}
# steps:
# - uses: actions/download-artifact@v2
# with:
# name: wheels
# - uses: actions/setup-python@v2
# - name: Publish to PyPi
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
# run: |
# pip install --upgrade twine
# twine upload --skip-existing *

1
Cargo.lock generated
View File

@ -1712,6 +1712,7 @@ dependencies = [
"common-path",
"dirs 4.0.0",
"fern",
"filetime",
"log",
"notify",
"pyo3",

View File

@ -5,7 +5,6 @@ edition = "2021"
[lib]
name = "ruff"
crate-type = ["cdylib", "lib"]
[dependencies]
anyhow = { version = "1.0.60" }
@ -18,6 +17,7 @@ colored = { version = "2.0.0" }
common-path = { version = "1.0.0" }
dirs = { version = "4.0.0" }
fern = { version = "0.6.1" }
filetime = "0.2.17"
log = { version = "0.4.17" }
notify = { version = "4.0.17" }
pyo3 = { version = "0.16.5", features = ["extension-module", "abi3-py37"] }

View File

@ -21,6 +21,7 @@ author = "Charlie Marsh"
author_email = "charlie.r.marsh@gmail.com"
url = "https://github.com/charliermarsh/ruff"
description = "An extremely fast Python linter, written in Rust."
requires-python = ">=3.7"
[build-system]
requires = ["maturin>=0.13,<0.14"]
@ -28,3 +29,5 @@ build-backend = "maturin"
[tool.maturin]
bindings = "bin"
sdist-include = ["Cargo.lock"]
strip = true

View File

@ -1,9 +1,9 @@
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::os::unix::fs::MetadataExt;
use std::path::Path;
use cacache::Error::EntryNotFound;
use filetime::FileTime;
use log::error;
use serde::{Deserialize, Serialize};
@ -14,7 +14,6 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
#[derive(Serialize, Deserialize)]
struct CacheMetadata {
size: u64,
mtime: i64,
}
@ -90,7 +89,7 @@ pub fn get(path: &Path, settings: &Settings, mode: &Mode) -> Option<Vec<Message>
Ok(encoded) => match path.metadata() {
Ok(m) => match bincode::deserialize::<CheckResult>(&encoded[..]) {
Ok(CheckResult { metadata, messages }) => {
if m.size() == metadata.size && m.mtime() == metadata.mtime {
if FileTime::from_last_modification_time(&m).unix_seconds() == metadata.mtime {
return Some(messages);
}
}
@ -112,8 +111,7 @@ pub fn set(path: &Path, settings: &Settings, messages: &[Message], mode: &Mode)
if let Ok(metadata) = path.metadata() {
let check_result = CheckResultRef {
metadata: &CacheMetadata {
size: metadata.size(),
mtime: metadata.mtime(),
mtime: FileTime::from_last_modification_time(&metadata).unix_seconds(),
},
messages,
};