Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-implement Nix CI workflow on GitHub instead of CircleCI #10

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
52cf658
Update the Nix flake to follow only nixos-24_05
btlogy Dec 3, 2024
2bc29b5
Our flake can only support Python 3.10 and 3.11
btlogy Dec 3, 2024
c13e42f
Implement Nix CI workflow on GitHub instead of CircleCI
btlogy Dec 3, 2024
357d201
Update flake to use nixos-24_11
btlogy Dec 4, 2024
6985b38
FIXME: skip flake check for now becasue of imcompatibility
btlogy Dec 4, 2024
93c5fd9
Update PyOpenSSL to the second-latest version
hacklschorsch Nov 5, 2024
e03a5dc
Drop our vendored pycddl, upstream has our fixes now
hacklschorsch Dec 4, 2024
b9f3fd3
Update nixpkgs in github workflow definition too
hacklschorsch Dec 4, 2024
2d56be5
Klein asks for hypothesis to run its tests
hacklschorsch Dec 4, 2024
f39b28d
Use the nixpkgs-provided klein
hacklschorsch Dec 4, 2024
e4e1085
Use the nixpkgs-provided pyopenssl
hacklschorsch Dec 4, 2024
dc19ef7
Use the nixpkgs-provided twisted
hacklschorsch Dec 4, 2024
0019e78
Use nixpkgs-provided txtorcon
hacklschorsch Dec 4, 2024
646b38b
Use nixpkgs-provided txi2p-tahoe
hacklschorsch Dec 4, 2024
201db29
Forgot to remove service-identity.nix which belonged to our pyopenssl…
hacklschorsch Dec 4, 2024
da7ecb8
Spell txi2p correctly
hacklschorsch Dec 4, 2024
a96a73e
Also run CI for Python 3.12
hacklschorsch Dec 4, 2024
5351714
Allow Python 3.12
hacklschorsch Dec 4, 2024
a902401
Patch _version.py
hacklschorsch Dec 4, 2024
e9f8c3d
The missing version fails a unit test - does this help?
hacklschorsch Dec 4, 2024
68f706e
Don't test Python 3.10 on NixOS 24.11
hacklschorsch Dec 5, 2024
371854b
Remove check step
hacklschorsch Dec 5, 2024
a4a9c89
Don't test obsolete Python 3.11, don't depend on check phase
hacklschorsch Dec 5, 2024
6d99d58
Does this create the environment variables?
hacklschorsch Dec 5, 2024
c1f16bc
Setting the env vars already requires Nix
hacklschorsch Dec 5, 2024
740759b
Remove input overriding
hacklschorsch Dec 5, 2024
0c0b835
Try out what the default number of cores does on GitHub Actions
hacklschorsch Dec 5, 2024
e825c12
Restore old / more generic version guard
hacklschorsch Dec 5, 2024
81e283e
Have fewer outdated comments
hacklschorsch Dec 5, 2024
ec3908b
Revert "Try out what the default number of cores does on GitHub Actions"
hacklschorsch Dec 5, 2024
7042baf
Remove NixOS jobs from CircleCI
hacklschorsch Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 0 additions & 115 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,6 @@ workflows:
- "oraclelinux-8":
{}

- "nixos":
name: "<<matrix.pythonVersion>>"
nixpkgs: "nixpkgs-unstable"
matrix:
parameters:
pythonVersion:
- "python39"
- "python310"
- "python311"

# Eventually, test against PyPy 3.8
#- "pypy27-buster":
# {}
Expand Down Expand Up @@ -574,40 +564,6 @@ jobs:
image: "tahoelafsci/fedora:35-py3"
user: "nobody"

nixos:
parameters:
nixpkgs:
description: >-
Reference the name of a flake-managed nixpkgs input (see `nix flake
metadata` and flake.nix)
type: "string"
pythonVersion:
description: >-
Reference the name of a Python package in nixpkgs to use.
type: "string"

executor: "nix"

steps:
- "nix-build":
nixpkgs: "<<parameters.nixpkgs>>"
pythonVersion: "<<parameters.pythonVersion>>"
buildSteps:
- "run":
name: "Unit Test"
command: |
source .circleci/lib.sh

# Translate the nixpkgs selection into a flake reference we
# can use to override the default nixpkgs input.
NIXPKGS=$(nixpkgs_flake_reference <<parameters.nixpkgs>>)

cache_if_able nix run \
--override-input nixpkgs "$NIXPKGS" \
.#<<parameters.pythonVersion>>-unittest -- \
--jobs $UNITTEST_CORES \
allmydata

typechecks:
docker:
- <<: *DOCKERHUB_AUTH
Expand Down Expand Up @@ -737,74 +693,3 @@ executors:
shell: "powershell.exe -ExecutionPolicy Bypass"
resource_class: "windows.large"

nix:
docker:
# Run in a highly Nix-capable environment.
- <<: *DOCKERHUB_AUTH
image: "nixos/nix:2.16.1"
environment:
# CACHIX_AUTH_TOKEN is manually set in the CircleCI web UI and allows us
# to push to CACHIX_NAME. CACHIX_NAME tells cachix which cache to push
# to.
CACHIX_NAME: "tahoe-lafs-opensource"
# Let us use features marked "experimental". For example, most/all of
# the `nix <subcommand>` forms.
NIX_CONFIG: "experimental-features = nix-command flakes"

commands:
nix-build:
parameters:
nixpkgs:
description: >-
Reference the name of a flake-managed nixpkgs input (see `nix flake
metadata` and flake.nix)
type: "string"
pythonVersion:
description: >-
Reference the name of a Python package in nixpkgs to use.
type: "string"
buildSteps:
description: >-
The build steps to execute after setting up the build environment.
type: "steps"

steps:
- "run":
# Get cachix for Nix-friendly caching.
name: "Install Basic Dependencies"
command: |
# Get some build environment dependencies and let them float on a
# certain release branch. These aren't involved in the actual
# package build (only in CI environment setup) so the fact that
# they float shouldn't hurt reproducibility.
NIXPKGS="nixpkgs/nixos-23.05"
nix profile install $NIXPKGS#cachix $NIXPKGS#bash $NIXPKGS#jp

# Activate our cachix cache for "binary substitution". This sets
# up configuration tht lets Nix download something from the cache
# instead of building it locally, if possible.
cachix use "${CACHIX_NAME}"

- "checkout"

- "run":
# The Nix package doesn't know how to do this part, unfortunately.
name: "Generate version"
command: |
nix-shell \
-p 'python3.withPackages (ps: [ ps.setuptools ])' \
--run 'python setup.py update_version'

- "run":
name: "Build Package"
command: |
source .circleci/lib.sh
NIXPKGS=$(nixpkgs_flake_reference <<parameters.nixpkgs>>)
cache_if_able nix build \
--verbose \
--print-build-logs \
--cores "$DEPENDENCY_CORES" \
--override-input nixpkgs "$NIXPKGS" \
.#<<parameters.pythonVersion>>-tahoe-lafs

- steps: "<<parameters.buildSteps>>"
87 changes: 87 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Nix

on:
push:
branches:
- main
paths:
- '.github/workflows/nix.yml'
- 'flake.*'
- 'setup.cfg'
- '*.nix'
- '*.py'
- '*.ini'
pull_request:
paths:
- '.github/workflows/nix.yml'
- 'flake.*'
- 'setup.cfg'
- '*.nix'
- '*.py'
- '*.ini'

jobs:
packaging:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version:
- 312
nixpkgs:
- nixos-24_11
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Install nix
id: install_nix
uses: nixbuild/nix-quick-install-action@v28

- name: Restore and cache Nix store for nixpkgs-${{ matrix.nixpkgs }}
uses: nix-community/cache-nix-action@v5
with:
# restore and save a cache using this key
primary-key: python${{ matrix.python-version }}-nixpkgs-${{ matrix.nixpkgs }}-${{ hashFiles('flake.*', '*.nix') }}
# if there's no cache hit, restore a cache by this prefix
restore-prefixes-first-match: nixpkgs-${{ matrix.nixpkgs }}-
# collect garbage until Nix store size (in bytes) is at most this number
# before trying to save a new cache
gc-max-store-size-linux: 1073741824
# do purge caches
purge: true
# purge all versions of the cache
purge-prefixes: python${{ matrix.python-version }}-nixpkgs-${{ matrix.nixpkgs }}-
# created more than 0 seconds ago relative to the start of the `Post Restore` phase
purge-created: 0
# except the version with the `primary-key`, if it exists
purge-primary-key: never

- name: Build package
env:
# CircleCI build environment looks like it has a zillion and a half cores.
# Don't let Nix autodetect this high core count because it blows up memory
# usage and fails the test run. Pick a number of cores that suits the build
# environment we're paying for (the free one!).
DEPENDENCY_CORES: 3
run: |
nix build \
--verbose \
--print-build-logs \
--cores "$DEPENDENCY_CORES" \
.#python${{ matrix.python-version }}-tahoe-lafs

- name: Unit test
env:
# Once dependencies are built, we can allow some more concurrency for our own
# test suite.
UNITTEST_CORES: 8
run: |
nix run \
.#python${{ matrix.python-version }}-unittest -- \
--jobs $UNITTEST_CORES \
allmydata
60 changes: 13 additions & 47 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 4 additions & 25 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
{
description = "Tahoe-LAFS, free and open decentralized data store";

nixConfig = {
# Supply configuration for the build cache updated by our CI system. This
# should allow most users to avoid having to build a large number of
# packages (otherwise necessary due to our Python package overrides).
substituters = ["https://tahoe-lafs-opensource.cachix.org"];
trusted-public-keys = ["tahoe-lafs-opensource.cachix.org-1:eIKCHOPJYceJ2gb74l6e0mayuSdXqiavxYeAio0LFGo="];
};

inputs = {
# A couple possible nixpkgs pins. Ideally these could be selected easily
# from the command line but there seems to be no syntax/support for that.
Expand All @@ -20,25 +12,12 @@
# requirements. We could decide in the future that supporting multiple
# releases of NixOS at a time is worthwhile and then pins like these will
# help us test each of those releases.
"nixpkgs-22_11" = {
url = github:NixOS/nixpkgs?ref=nixos-22.11;
};
"nixpkgs-23_05" = {
url = github:NixOS/nixpkgs?ref=nixos-23.05;
};

# We depend on a very new python-cryptography which is not yet available
# from any release branch of nixpkgs. However, it is contained in a PR
# currently up for review. Point our nixpkgs at that for now.
"nixpkgs-unstable" = {
url = github:NixOS/nixpkgs?ref=pull/244135/head;
"nixpkgs-24_11" = {
url = github:NixOS/nixpkgs?ref=nixos-24.11;
};

# Point the default nixpkgs at one of those. This avoids having getting a
# _third_ package set involved and gives a way to provide what should be a
# working experience by default (that is, if nixpkgs doesn't get
# overridden).
nixpkgs.follows = "nixpkgs-unstable";
# Point the default nixpkgs at one of those.
nixpkgs.follows = "nixpkgs-24_11";

# Also get flake-utils for simplified multi-system definitions.
flake-utils = {
Expand Down
9 changes: 0 additions & 9 deletions nix/klein.nix

This file was deleted.

Loading
Loading