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

Use latest python-black to format the sources #2599

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions .github/workflows/nix-github-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Nix Flake actions

on: push
# pull_request:
# push:
# branches:
# - master
# - main

jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v24
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
matrix="$(nix eval --json '.#githubActions.matrix')"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"

nix-build:
needs: nix-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v24
- run: nix build -L ".#${{ matrix.attr }}"
20 changes: 16 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@ def pytest_addoption(parser):

# report data to feature parity dashboard
parser.addoption(
"--report-run-url", type=str, action="store", default=None, help="URI of the run who produced the report",
"--report-run-url",
type=str,
action="store",
default=None,
help="URI of the run who produced the report",
)
parser.addoption(
"--report-environment", type=str, action="store", default=None, help="The environment the test is run under",
"--report-environment",
type=str,
action="store",
default=None,
help="The environment the test is run under",
)


Expand Down Expand Up @@ -353,13 +361,17 @@ def pytest_sessionfinish(session, exitstatus):
if not hasattr(session.config, "workerinput"):
with open(f"{context.scenario.host_log_folder}/known_versions.json", "w", encoding="utf-8") as f:
json.dump(
{library: sorted(versions) for library, versions in LibraryVersion.known_versions.items()}, f, indent=2,
{library: sorted(versions) for library, versions in LibraryVersion.known_versions.items()},
f,
indent=2,
)

data = session.config._json_report.report # pylint: disable=protected-access

junit_modifyreport(
data, session.config.option.xmlpath, junit_properties=context.scenario.get_junit_properties(),
data,
session.config.option.xmlpath,
junit_properties=context.scenario.get_junit_properties(),
)

export_feature_parity_dashboard(session, data)
Expand Down
1 change: 1 addition & 0 deletions docs/architecture/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# - Skip for every library except one
# @irrelevant(context.library = "dotnet", reason="only for .NET")


# To run an individual test: ./run.sh tests/test_traces.py::Test_Misc::test_main
class Test_Misc:
"""*ATTENTION*: This is where you summarize the test"""
Expand Down
185 changes: 185 additions & 0 deletions flake.lock

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

118 changes: 118 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
description = "sys-tests";
nixConfig.bash-prompt-prefix = "\[system-tests\] ";

inputs = {
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
nix2containerPkg.url = "github:nlewo/nix2container";

nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin";

nix-github-actions.url = "github:nix-community/nix-github-actions";
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = {
self,
nixpkgs,
flake-utils,
treefmt-nix,
nix2containerPkg,
nix-github-actions,
}:
(flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};

black = pkgs.black;

nix2container = nix2containerPkg.packages.${system}.nix2container;

pythonWithPkgs = pkgs.python39.withPackages (pythonPkgs:
with pythonPkgs; [
pip
virtualenvwrapper
]);

treefmt = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;

previewMarkdown = pkgs.writeScriptBin "preview" ''
#!${pkgs.bash}/bin/bash
${pkgs.gh-markdown-preview}/bin/gh-markdown-preview "$@"
'';

devtools = pkgs.symlinkJoin {
name = "devtools";
paths = [
pkgs.curl
pkgs.bash
pkgs.coreutils
pkgs.fswatch
pkgs.rsync
pkgs.shellcheck
pythonWithPkgs
treefmt.config.build.wrapper
];
postBuild = "echo links added";
};
in {
packages = {
default = devtools;

inherit devtools previewMarkdown black;

### Build image usable in CI with dependencies
## nix run .#ciContainer.copyToDockerDaemon
## docker run --rm -it ci # to run the ci image
ciContainer = nix2container.buildImage {
name = "ci";
tag = "latest";
config = {
entrypoint = ["/bin/bash"];
};
copyToRoot = pkgs.buildEnv {
name = "root";
paths = [
devtools
];
pathsToLink = ["/bin"];
};
};
};
devShells.default =
pkgs.mkShell
{
packages = [
devtools
];
shellHook = ''
export PYTHON_VERSION="$(python -c 'import platform; import re; print(re.sub(r"\.\d+$", "", platform.python_version()))')"

# replicate virtualenv behaviour
export PIP_PREFIX="$PWD/vendor/python/$PYTHON_VERSION/packages"
export PYTHONPATH="$PIP_PREFIX/lib/python$PYTHON_VERSION/site-packages:$PYTHONPATH"
unset SOURCE_DATE_EPOCH
export PATH="$PIP_PREFIX/bin:$PATH"

# hack: can't find libstdc++.so.8 otherwise
# pawel: hack-disabled as this breaks everythin on my system
# export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib"
'';
};

formatter = treefmt.config.build.wrapper;
checks = {
formatting = treefmt.config.build.check self;
};
}))
// {
githubActions = nix-github-actions.lib.mkGithubMatrix {
checks = {
inherit (self.checks) x86_64-linux;
x86_64-darwin = builtins.removeAttrs self.checks.x86_64-darwin ["formatting"];
};
};
};
}
Loading
Loading