Skip to content

Commit

Permalink
Lint (#13)
Browse files Browse the repository at this point in the history
* Lint

* Add build workflow
  • Loading branch information
t-young31 authored Aug 28, 2023
1 parent 4d1127c commit 97dfa64
Show file tree
Hide file tree
Showing 45 changed files with 7,084 additions and 1,919 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
name: Publish

on:
push:
tags:
- "0.*"

jobs:
linux:
runs-on: "ubuntu-latest"
environment: pypi
strategy:
fail-fast: true
matrix:
python-version: [ "3.9", "3.10", "3.11" ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Create publish script
run: |
cat <<EOF > publish.sh
#!/bin/bash
docker run --rm -v $(pwd):/io ghcr.io/pyo3/maturin \
build --interpreter ${{ matrix.python-version }} --release --strip
#docker run --rm -v $(pwd):/io -e MATURIN_PYPI_TOKEN="\$1" \
# ghcr.io/pyo3/maturin publish --interpreter ${{ matrix.python-version }}
EOF
chmod +x publish.sh
- name: Publish optrs
run: |
./publish.sh "${{ secrets.OPT_RS_UPLOAD_TOKEN }}"
- name: Publish optrs-api
run: |
cd api
../publish.sh "${{ secrets.OPT_RS_API_UPLOAD_TOKEN }}"
mac:
runs-on: "macos-latest"
strategy:
fail-fast: true
matrix:
python-version: [ "3.9", "3.10", "3.11" ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install maturin
run: pip install maturin

- name: Publish optrs
env:
MATURIN_PYPI_TOKEN: ${{ secrets.OPT_RS_UPLOAD_TOKEN }}
run: |
maturin build --release --strip --universal2 #&& maturin publish
- name: Publish optrs-api
env:
MATURIN_PYPI_TOKEN: ${{ secrets.OPT_RS_API_UPLOAD_TOKEN }}
run: |
cd api
maturin build --release --strip --universal2 #&& maturin publish
15 changes: 10 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
---
name: Test

on:
push:
branches: [ main ]
pull_request:

name: Test

jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
PROJECT_NAME_UNDERSCORE: optrs
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
RUSTDOCFLAGS: -Cpanic=abort
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: Cache dependencies
uses: actions/cache@v2
env:
Expand All @@ -34,18 +36,21 @@ jobs:
~/.cargo/registry/cache
target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}

- name: Generate test result and coverage report
run: |
cargo install cargo2junit grcov;
cargo test $CARGO_OPTIONS --bins -- -Z unstable-options --format json | cargo2junit > results.xml;
zip -0 ccov.zip `find . \( -name "$PROJECT_NAME_UNDERSCORE*.gc*" \) -print`;
grcov ccov.zip -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov.info;
- name: Upload test results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
check_name: Test Results
github_token: ${{ secrets.GITHUB_TOKEN }}
files: results.xml

- name: Upload to CodeCov
uses: codecov/codecov-action@v1
with:
Expand Down
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-toml

- repo: https://github.com/t-young31/pre-commit-hooks
rev: 0.1.3
hooks:
- id: stale-version

- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
- id: cargo-check

- repo: local
hooks:
- id: clippy
name: clippy
description: Lint rust sources
entry: cargo clippy
language: system
args: [ "--", "-A", "warnings"]
types: [ rust ]
pass_filenames: false
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "optrs"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
authors = ["Tom Young"]
license = "MIT OR Apache-2.0"
keywords = ["optimization", "chemistry"]
repository = "https://github.com/t-young31/opt-rs"
homepage = "https://github.com/t-young31/opt-rs"
description = "Forcefield molecule optimization"
description = "Molecular molecule optimization with forcefields"
readme = "README.md"

[[bin]]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
**optrs** is a lightweight molecular mechanics optimisation code written in rust.

***
### Installation
### Installation
Install the binary with

```bash
Expand All @@ -22,7 +22,7 @@ Optimise a molecule provided as a [.xyz](https://en.wikipedia.org/wiki/XYZ_file_
optrs molecule.xyz
```

which will generate _opt.xyz_ in working directory.
which will generate _opt.xyz_ in working directory.
[API examples](https://github.com/t-young31/opt-rs/tree/main/api/examples).

***
Expand Down
2 changes: 1 addition & 1 deletion api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "optrs"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
authors = ["Tom Young"]

Expand Down
Loading

0 comments on commit 97dfa64

Please sign in to comment.