Skip to content

Commit

Permalink
Merge 72739b0 into fc413d4
Browse files Browse the repository at this point in the history
  • Loading branch information
exarkun committed Aug 8, 2023
2 parents fc413d4 + 72739b0 commit d98d70c
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 15 deletions.
108 changes: 108 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ version: 2.1
dockerhub-context-template: &DOCKERHUB_CONTEXT
context: "dockerhub-auth"

# Required environment for using the coveralls tool to upload partial coverage
# reports and then finish the process.
coveralls-environment: &COVERALLS_ENVIRONMENT
COVERALLS_REPO_TOKEN: "JPf16rLB7T2yjgATIxFzTsEgMdN1UNq6o"

# Next is a Docker executor template that gets the credentials from the
# environment and supplies them to the executor.
dockerhub-auth-template: &DOCKERHUB_AUTH
Expand Down Expand Up @@ -112,6 +117,14 @@ workflows:
- "another-locale":
{}

- "windows-server-2022":
name: "Windows Server 2022, Python <<matrix.pythonVersion>>"
matrix:
parameters:
pythonVersion:
- "3.9"
- "3.11"

- "integration":
# Run even the slow integration tests here. We need the `--` to
# sneak past tox and get to pytest.
Expand All @@ -126,13 +139,32 @@ workflows:
- "docs":
{}

- "finish-coverage-report":
requires:
- "Windows Server 2022, Python 3.9"
- "Windows Server 2022, Python 3.11"

images:
<<: *IMAGES

# Build as part of the workflow but only if requested.
when: "<< pipeline.parameters.build-images >>"

jobs:
finish-coverage-report:
docker:
- <<: *DOCKERHUB_AUTH
image: "python:3-slim"

steps:
- run:
name: "Indicate completion to coveralls.io"
environment:
<<: *COVERALLS_ENVIRONMENT
command: |
pip install coveralls==3.2.0
python -m coveralls --finish
codechecks:
docker:
- <<: *DOCKERHUB_AUTH
Expand All @@ -151,6 +183,73 @@ jobs:
command: |
~/.local/bin/tox -e codechecks
windows-server-2022:
parameters:
pythonVersion:
description: >-
An argument to pass to the `py` launcher to choose a Python version.
type: "string"
default: ""

executor: "windows"
environment:
TAHOE_LAFS_HYPOTHESIS_PROFILE: "ci"

steps:
- "checkout"

- "run":
name: "Display tool versions"
command: |
py -<<parameters.pythonVersion>> misc/build_helpers/show-tool-versions.py
- "run":
name: "Install Dependencies"
command: |
py -<<parameters.pythonVersion>> -m pip install .[testenv] .[test]
- "run":
name: "Run Unit Tests"
environment:
SUBUNITREPORTER_OUTPUT_PATH: "test-results.subunit2"
PYTHONUNBUFFERED: "1"
command: |
py -<<parameters.pythonVersion>> -b -m coverage run -m twisted.trial --reporter=subunitv2-file --rterrors allmydata
- "run":
name: "Upload Coverage"
environment:
<<: *COVERALLS_ENVIRONMENT
# Mark the data as just one piece of many because we have more
# than one instance of this job (two on Windows now, some on other
# platforms later) which collects and reports coverage. This is
# necessary to cause Coveralls to merge multiple coverage results
# into a single report. Note the merge only happens when we
# "finish" a particular build, as identified by its "build_num"
# (aka "service_number").
COVERALLS_PARALLEL: "true"
command: |
py -<<parameters.pythonVersion>> -m pip install coveralls
py -<<parameters.pythonVersion>> -m coveralls
- "run":
name: "Convert Result Log"
command: |
# The Python for which we installed subunit is not necessarily on
# %PATH% so (possibly) re-install it with the default Python.
python -m pip install subunit2junitxml junitxml
Start-Process subunit2junitxml -Wait -RedirectStandardInput test-results.subunit2 -RedirectStandardOutput test-results.xml
- "store_test_results":
path: "test-results.xml"

- "store_artifacts":
path: "_trial_temp/test.log"

- "store_artifacts":
path: "eliot.log"

pyinstaller:
docker:
- <<: *DOCKERHUB_AUTH
Expand Down Expand Up @@ -527,6 +626,15 @@ jobs:
# PYTHON_VERSION: "2"

executors:
windows:
# Choose a Windows environment that closest matches our testing
# requirements and goals.
# https://circleci.com/developer/orbs/orb/circleci/windows#executors-server-2022
machine:
image: "windows-server-2022-gui:2023.06.1"
shell: "powershell.exe -ExecutionPolicy Bypass"
resource_class: "windows.large"

nix:
docker:
# Run in a highly Nix-capable environment.
Expand Down
4 changes: 3 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ skip_covered = True
source =
# It looks like this in the checkout
src/
# It looks like this in the Windows build environment
# It looks like this in the GitHub Actions Windows build environment
D:/a/tahoe-lafs/tahoe-lafs/.tox/py*-coverage/Lib/site-packages/
# Although sometimes it looks like this instead. Also it looks like this on macOS.
.tox/py*-coverage/lib/python*/site-packages/
# And on the CircleCI Windows build envronment...
.tox/py*-coverage/Lib/site-packages/
# On some Linux CI jobs it looks like this
/tmp/tahoe-lafs.tox/py*-coverage/lib/python*/site-packages/
7 changes: 0 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ jobs:
strategy:
fail-fast: false
matrix:
os:
- windows-latest
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
include:
# On macOS don't bother with 3.8, just to get faster builds.
- os: macos-12
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def run(self):
"pip==22.0.3",
"wheel==0.37.1",
"setuptools==60.9.1",
"subunitreporter==22.2.0",
"subunitreporter==23.8.0",
"python-subunit==1.4.2",
"junitxml==0.7",
"coverage==7.2.5",
Expand Down
6 changes: 4 additions & 2 deletions src/allmydata/test/cli/test_grid_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from ..common_util import (
run_cli,
)
from ..common import (
superuser,
)
from twisted.internet.defer import (
inlineCallbacks,
)
Expand All @@ -34,7 +37,6 @@
)
from allmydata.util import jsonbytes as json


class GridManagerCommandLine(TestCase):
"""
Test the mechanics of the `grid-manager` command
Expand Down Expand Up @@ -223,7 +225,7 @@ def test_sign_missing(self):
)

@skipIf(platform.isWindows(), "We don't know how to set permissions on Windows.")
@skipIf(os.getuid() == 0, "cannot test as superuser with all permissions")
@skipIf(superuser, "cannot test as superuser with all permissions")
def test_sign_bad_perms(self):
"""
Error reported if we can't create certificate file
Expand Down
4 changes: 4 additions & 0 deletions src/allmydata/test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
PIPE,
)

# Is the process running as an OS user with elevated privileges (ie, root)?
# We only know how to determine this for POSIX systems.
superuser = getattr(os, "getuid", lambda: -1)() == 0

EMPTY_CLIENT_CONFIG = config_from_string(
"/dev/null",
"tub.port",
Expand Down
3 changes: 2 additions & 1 deletion src/allmydata/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
from foolscap.api import flushEventualQueue
import allmydata.test.common_util as testutil
from .common import (
superuser,
EMPTY_CLIENT_CONFIG,
SyncTestCase,
AsyncBrokenTestCase,
Expand Down Expand Up @@ -151,7 +152,7 @@ def write_config(s):
# EnvironmentError when reading a file that really exists), on
# windows, please fix this
@skipIf(platform.isWindows(), "We don't know how to set permissions on Windows.")
@skipIf(os.getuid() == 0, "cannot test as superuser with all permissions")
@skipIf(superuser, "cannot test as superuser with all permissions")
def test_unreadable_config(self):
basedir = "test_client.Basic.test_unreadable_config"
os.mkdir(basedir)
Expand Down
7 changes: 4 additions & 3 deletions src/allmydata/test/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
ConstantAddresses,
SameProcessStreamEndpointAssigner,
UseNode,
superuser,
)

def port_numbers():
Expand Down Expand Up @@ -325,7 +326,7 @@ def test_config_items_missing_section(self):
self.assertEqual(config.items("nosuch", default), default)

@skipIf(platform.isWindows(), "We don't know how to set permissions on Windows.")
@skipIf(os.getuid() == 0, "cannot test as superuser with all permissions")
@skipIf(superuser, "cannot test as superuser with all permissions")
def test_private_config_unreadable(self):
"""
Asking for inaccessible private config is an error
Expand All @@ -341,7 +342,7 @@ def test_private_config_unreadable(self):
config.get_or_create_private_config("foo")

@skipIf(platform.isWindows(), "We don't know how to set permissions on Windows.")
@skipIf(os.getuid() == 0, "cannot test as superuser with all permissions")
@skipIf(superuser, "cannot test as superuser with all permissions")
def test_private_config_unreadable_preexisting(self):
"""
error if reading private config data fails
Expand Down Expand Up @@ -398,7 +399,7 @@ def make_newer():
self.assertEqual(len(counter), 1) # don't call unless necessary
self.assertEqual(value, "newer")

@skipIf(os.getuid() == 0, "cannot test as superuser with all permissions")
@skipIf(superuser, "cannot test as superuser with all permissions")
def test_write_config_unwritable_file(self):
"""
Existing behavior merely logs any errors upon writing
Expand Down

0 comments on commit d98d70c

Please sign in to comment.