From eb9b9c53f66cfb114201e0e71eaca440036a2f06 Mon Sep 17 00:00:00 2001 From: Fabian Schwarzer Date: Thu, 7 Mar 2024 21:42:05 +0100 Subject: [PATCH 1/2] replace flake with devenv --- .envrc | 3 + .gitignore | 11 ++++ devenv.lock | 156 +++++++++++++++++++++++++++++++++++++++++++++++++ devenv.nix | 23 ++++++++ devenv.yaml | 3 + src/flake.lock | 26 --------- src/flake.nix | 50 ---------------- 7 files changed, 196 insertions(+), 76 deletions(-) create mode 100644 .envrc create mode 100644 devenv.lock create mode 100644 devenv.nix create mode 100644 devenv.yaml delete mode 100644 src/flake.lock delete mode 100644 src/flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..6de8a8a --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0=" + +use devenv \ No newline at end of file diff --git a/.gitignore b/.gitignore index e8783de..49c8c37 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,14 @@ src/env/ src/.idea/ *.pyc + +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml + diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..e05d4ff --- /dev/null +++ b/devenv.lock @@ -0,0 +1,156 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1709750969, + "narHash": "sha256-LDTZ2aRlnXSwYZnUnv6cJ3WQp8LmDYKMtouv2gTQmAA=", + "owner": "cachix", + "repo": "devenv", + "rev": "e53e5cc77bb6e1073b136ec98a0a9cfbb582c7a8", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703887061, + "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1709780214, + "narHash": "sha256-p4iDKdveHMhfGAlpxmkCtfQO3WRzmlD11aIcThwPqhk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f945939fd679284d736112d3d5410eb867f3b31c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1704874635, + "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1708018599, + "narHash": "sha256-M+Ng6+SePmA8g06CmUZWi1AjG2tFBX9WCXElBHEKnyM=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "5df5a70ad7575f6601d91f0efec95dd9bc619431", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + }, + "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/devenv.nix b/devenv.nix new file mode 100644 index 0000000..709d220 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,23 @@ +{ pkgs, ... }: + +{ + packages = [ + pkgs.chromedriver + # pkgs.chromium + ]; + + languages.python = { + enable = true; + venv = { + enable = true; + requirements = '' + requests + oyaml + selenium + pytest + pyyaml + jinja2 + ''; + }; + }; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..c7cb5ce --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,3 @@ +inputs: + nixpkgs: + url: github:NixOS/nixpkgs/nixpkgs-unstable diff --git a/src/flake.lock b/src/flake.lock deleted file mode 100644 index 639ed25..0000000 --- a/src/flake.lock +++ /dev/null @@ -1,26 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1664912021, - "narHash": "sha256-ecnQfOSxhbj0x99jcX72lfo193IexLJQ07ojOXMgruY=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "603bdef4c7b21a5ae9f23f63950e95c177ff18b5", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/src/flake.nix b/src/flake.nix deleted file mode 100644 index 42e2576..0000000 --- a/src/flake.nix +++ /dev/null @@ -1,50 +0,0 @@ -{ - inputs = { - nixpkgs.url = "github:nixos/nixpkgs"; - }; - - outputs = { self, nixpkgs }: - let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - pythonTest = pkgs.python3.withPackages (ps: with ps; - [ pytest ]); - pythonReadmeAndMap = pkgs.python3.withPackages (ps: with ps; - [ - pyyaml - jinja2 - ]); - pythonReviews = pkgs.python3.withPackages (ps: with ps; - [ - requests - oyaml - selenium - ]); - in - { - devShells.${system} = { - test = pkgs.mkShell { - buildInputs = [ pythonTest ]; - }; - readmeAndMap = pkgs.mkShell { - buildInputs = [ pythonReadmeAndMap ]; - }; - reviews = pkgs.mkShell { - buildInputs = [ - pythonReviews - pkgs.chromedriver - pkgs.chromium - ]; - }; - develop = pkgs.mkShell { - buildInputs = [ - pythonTest - pythonReviews - pythonReadmeAndMap - - ]; - }; - - }; - }; -} From e941bfcdfd50056aec43da1e1be0bd297640510a Mon Sep 17 00:00:00 2001 From: Fabian Schwarzer Date: Fri, 8 Mar 2024 16:13:36 +0100 Subject: [PATCH 2/2] update github actions to run with devenv --- .github/workflows/ratings.yml | 24 ++++++++++++++++-------- .github/workflows/update.yml | 30 ++++++++++++++++++++---------- devenv.nix | 19 +++++++++++++++++++ 3 files changed, 55 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ratings.yml b/.github/workflows/ratings.yml index 0e1b2ac..8839bbd 100644 --- a/.github/workflows/ratings.yml +++ b/.github/workflows/ratings.yml @@ -14,21 +14,29 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2.4.0 + uses: actions/checkout@v4.1.1 - name: Install Nix - uses: cachix/install-nix-action@v18 + uses: cachix/install-nix-action@v26 + + - name: Use Cachix + uses: cachix/cachix-action@v12 with: - extra_nix_config: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + name: devenv + + - name: Install devenv.sh + run: nix profile install --accept-flake-config tarball+https://install.devenv.sh/latest + + - name: Build the devenv shell and run any pre-commit hooks + run: devenv ci - name: Run tests - run: cd src && nix develop .#test -c pytest + run: devenv shell run_tests - - name: Run update_reviews.py - run: cd src && nix develop .#reviews -c python update_reviews.py + - name: Run update_reviews + run: devenv shell update_reviews - name: Add & Commit - uses: EndBug/add-and-commit@v7.1.0 + uses: EndBug/add-and-commit@v9.1.4 with: message: update data.yaml via update_reviews.py diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index d23274c..2a86598 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -15,26 +15,36 @@ jobs: update_readme_and_map: runs-on: ubuntu-latest + + steps: - name: Checkout - uses: actions/checkout@v2.4.0 + uses: actions/checkout@v4.1.1 - name: Install Nix - uses: cachix/install-nix-action@v18 + uses: cachix/install-nix-action@v26 + + - name: Use Cachix + uses: cachix/cachix-action@v12 with: - extra_nix_config: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + name: devenv + + - name: Install devenv.sh + run: nix profile install --accept-flake-config tarball+https://install.devenv.sh/latest + + - name: Build the devenv shell and run any pre-commit hooks + run: devenv ci - name: Run tests - run: cd src && nix develop .#test -c pytest + run: devenv shell run_tests - - name: Run create_readme.py - run: cd src && nix develop .#readmeAndMap -c python create_readme.py + - name: Run create_readme + run: devenv shell create_readme - - name: Run create_map_data.py - run: cd src && nix develop .#readmeAndMap -c python create_map_data.py + - name: Run create_map_data + run: devenv shell create_map_data - name: Add & Commit - uses: EndBug/add-and-commit@v7.1.0 + uses: EndBug/add-and-commit@v9.1.4 with: message: update readme.md via create_readme.py diff --git a/devenv.nix b/devenv.nix index 709d220..211ca63 100644 --- a/devenv.nix +++ b/devenv.nix @@ -20,4 +20,23 @@ ''; }; }; + + scripts = { + create_readme.exec = '' + pushd src > /dev/null + python create_readme.py + popd > /dev/null + ''; + create_map_data.exec = '' + pushd src > /dev/null + python create_map_data.py + popd > /dev/null + ''; + update_reviews.exec = '' + pushd src > /dev/null + python update_reviews.py + popd > /dev/null + ''; + test.exec = "pytest src/test_all.py"; + }; }