diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a79149..7223376 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,11 +10,15 @@ concurrency: group: ci-${{github.ref}}-${{github.event.pull_request.number || github.run_number}} cancel-in-progress: true +permissions: {} + jobs: prechecks: uses: ./.github/workflows/pre-commit.yml - all-prechecks: - needs: [prechecks] + nix: + uses: ./.github/workflows/nix.yml + all: + needs: [prechecks, nix] runs-on: ubuntu-latest steps: - name: Success diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000..5f8da7b --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,33 @@ +--- +name: build and test nix package + +# yamllint disable-line rule:truthy +on: + workflow_dispatch: + workflow_call: + +concurrency: + group: nix-${{github.ref}}-${{github.event.pull_request.number || github.run_number}} + cancel-in-progress: true + +permissions: {} + +jobs: + nix-build: + runs-on: ubuntu-latest + steps: + # Install Nix on the runner + - uses: cachix/install-nix-action@17fe5fb4a23ad6cbbe47d6b3f359611ad276644c # v31 + with: + nix_path: nixpkgs=channel:nixos-unstable + # Pull from the cachix cache + - uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16 + with: + name: cclib + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + # Checkout of the current head in the working dir + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + with: + persist-credentials: false + - name: Check nix flake + run: nix flake check -L diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 90f3dd9..f578362 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -9,13 +9,17 @@ concurrency: group: style-${{github.ref}}-${{github.event.pull_request.number || github.run_number}} cancel-in-progress: true +permissions: {} + jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + with: + persist-credentials: false + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 - name: install dependencies for sorting regressionfiles.yaml run: | python -m pip install 'ruamel.yaml' - - uses: pre-commit/action@v3.0.1 + - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 diff --git a/.gitignore b/.gitignore index fc360ae..28d6399 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ *.pyc +.direnv .idea +.venv regressionfiles.diff regressionfiles.yaml.orig diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8e030ea..50a45d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,32 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: "v5.0.0" hooks: + - id: check-json - id: check-yaml + - id: trailing-whitespace + exclude: | + (?x)( + ^ADF| + ^DALTON| + ^FChk| + ^GAMESS| + ^GAMESSDAT| + ^GAMESS-UK| + ^Gaussian| + ^io| + ^Jaguar| + ^Molcas| + ^Molpro| + ^MOPAC| + ^NBO| + ^NWChem| + ^ORCA| + ^Psi3| + ^Psi4| + ^QChem| + ^Turbomole| + ^XTB + ) - repo: local hooks: - id: sort-regressionfiles-yaml @@ -21,7 +46,14 @@ repos: entry: ./sort_regressionfiles_yaml.sh language: script files: ^regressionfiles\.yaml$ - - repo: https://github.com/Mateusz-Grzelinski/actionlint-py - rev: "v1.7.7.23" + - repo: https://github.com/rhysd/actionlint + rev: "v1.7.7" hooks: - id: actionlint + additional_dependencies: + - "github.com/wasilibs/go-shellcheck/cmd/shellcheck@v0.10.0" + - repo: https://github.com/zizmorcore/zizmor-pre-commit + rev: "v1.9.0" + hooks: + - id: zizmor + args: [--no-progress, --persona=pedantic] diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..5ca5bd3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1749369410, + "narHash": "sha256-P1eYm8bewiyWg3QaPCHrOp6iWg/7ESi/aGHT4yilyNo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "8207ad0d501dd3590e0e81a7c56b386a5c4342c9", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ed468d4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,79 @@ +{ + description = "Parsers and algorithms for computational chemistry logfiles (regression data)"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + }: + let + /* + Change this value ({major}.{min}) to + update the Python virtual-environment + version. When you do this, make sure + to delete the `.venv` directory to + have the hook rebuild it for the new + version, since it won't overwrite an + existing one. After this, reload the + development shell to rebuild it. + You'll see a warning asking you to + do this when version mismatches are + present. For safety, removal should + be a manual step, even if trivial. + */ + version = "3.13"; + in + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShells.default = + let + concatMajorMinor = + v: + pkgs.lib.pipe v [ + pkgs.lib.versions.splitVersion + (pkgs.lib.sublist 0 2) + pkgs.lib.concatStrings + ]; + python = pkgs."python${concatMajorMinor version}"; + in + pkgs.mkShellNoCC { + venvDir = ".venv"; + + postShellHook = '' + venvVersionWarn() { + local venvVersion + venvVersion="$("$venvDir/bin/python" -c 'import platform; print(platform.python_version())')" + + [[ "$venvVersion" == "${python.version}" ]] && return + + cat <cclib/.github:renovate-config" ] }