Skip to content

Commit

Permalink
Package poetry from master, use it in actions
Browse files Browse the repository at this point in the history
  • Loading branch information
WeetHet committed Dec 20, 2024
1 parent 832b8b2 commit 53c30b4
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 1,969 deletions.
47 changes: 12 additions & 35 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install poetry
shell: bash
run: |
pip install poetry
poetry config virtualenvs.in-project true
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main

- name: Load dependency cache
id: load-cache
uses: actions/cache@v2
with:
path: .venv
key: app-${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: poetry install
if: steps.load-cache.outputs.cache-hit != 'true'
run: nix develop -c poetry install

- name: Check code style
if: github.event_name != 'push'
run: |
poetry run black --check --diff .
poetry run isort --check --diff .
nix develop -c poetry run black --check --diff .
nix develop -c poetry run isort --check --diff .
- name: Reformat code
if: github.event_name == 'push'
run: |
poetry run black .
poetry run isort .
nix develop -c poetry run black .
nix develop -c poetry run isort .
- name: Commit chanes
if: github.event_name == 'push'
shell: bash
Expand All @@ -69,26 +56,19 @@ jobs:
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install poetry
shell: bash
run: |
pip install poetry
poetry config virtualenvs.in-project true
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Load dependency cache
id: load-cache
uses: actions/cache@v2
with:
path: .venv
key: app-${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: poetry install
run: nix develop -c poetry install
if: steps.load-cache.outputs.cache-hit != 'true'

- name: Release
Expand All @@ -97,14 +77,12 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
source .venv/bin/activate
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
export GH_TOKEN="${GITHUB_TOKEN}"
export REPOSITORY_USERNAME="__token__"
export REPOSITORY_PASSWORD="${PYPI_TOKEN}"
python -m semantic_release publish -D commit_author="github-actions <[email protected]>"
nix develop -c poetry run python -m semantic_release publish -D commit_author="github-actions <[email protected]>"
- name: Save release commit hash
id: release-commit-hash
run: echo "::set-output name=release-commit-hash::$(git rev-parse HEAD)"
Expand All @@ -126,4 +104,3 @@ jobs:
with:
commit-hash: ${{ needs.Release.outputs.release-commit-hash }}
secrets: inherit

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

devShells.default = pkgs.mkShell {
packages = [
pkgs.poetry
(pkgs.callPackage ./nix/poetry-master.nix { })
python-semantic-release
(python.withPackages (
project.renderers.withPackages {
Expand Down
39 changes: 39 additions & 0 deletions nix/poetry-master.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{ pkgs }:
let
poetry-core = pkgs.python3Packages.poetry-core.overrideAttrs (old: {
version = "2.0.0.dev0";
src = pkgs.fetchFromGitHub {
owner = "python-poetry";
repo = "poetry-core";
rev = "4749d63c822147b0dbaa82033c02628f92c97200";
hash = "sha256-who4WpQXaA83e+Z6TN73bDSkPpNaFsjn1DIqYIVUEqk=";
};

doCheck = false;
pytestCheckPhase = ''true'';
});
in
pkgs.poetry.overridePythonAttrs (old: {
version = "2.0.0.dev0";

src = pkgs.fetchFromGitHub {
owner = "python-poetry";
repo = "poetry";
rev = "625f42ef96f8321f4e1649f38e39e71cd2b09f3e";
hash = "sha256-tBim3dlKdkcvWWGavHpv52HAZX1FvPh2S+FTKPMrZVs=";
};

propagatedBuildInputs = builtins.map (
x: if x.pname or "" == "poetry-core" then poetry-core else x
) old.propagatedBuildInputs;

pythonRelaxDeps = [
"dulwich"
"keyring"
"virtualenv"
"pkginfo"
];

doCheck = false;
postInstall = null;
})
Loading

0 comments on commit 53c30b4

Please sign in to comment.