Skip to content

Commit

Permalink
Merge branch 'main' into feature/cli-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisrink10 committed Aug 6, 2023
2 parents 713cb0f + f6bebc5 commit 44f1b3a
Show file tree
Hide file tree
Showing 123 changed files with 10,914 additions and 4,408 deletions.
187 changes: 35 additions & 152 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,188 +1,71 @@
version: 2.1

commands:
setup_tests:
description: "Check out code, install Tox, and prepare the test environment."
run_pypy_tests:
description: "Install Tox and run tests."
parameters:
python_version:
description: "Required. Python version as `major.minor`."
type: string
cache_key_prefix:
description: "Required. Prefix used for the CircleCI cache key."
type: string
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python<< parameters.python_version >>/site-packages
- restore_cache:
key: << parameters.cache_key_prefix >>1-{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
key: pypy-<< parameters.python_version >>-deps3-{{ checksum "tox.ini" }}-{{ checksum "pyproject.toml" }}
- run:
name: Install tox
shell: /bin/bash -leo pipefail
name: Install Poetry and Tox
command: |
pip install -U pip
apt-get update && apt-get install -y python3 python3-distutils curl
pip install -U pip virtualenv
pip install tox
teardown_tests:
description: "Store the cache for the current run."
parameters:
python_version:
description: "Required. Python version as `major.minor`."
type: string
cache_key_prefix:
description: "Required. Prefix used for the CircleCI cache key."
type: string
steps:
curl -sSL https://install.python-poetry.org | python3 -
echo 'export PATH="/root/.local/bin:$PATH"' >> $BASH_ENV
- run:
name: Run Tests
command: |
CCI_NODE_TESTS=$(circleci tests glob "tests/**/*_test.*py" "tests/**/test_*.*py" | circleci tests split --split-by=timings)
printf "Test files:\n"
echo "$CCI_NODE_TESTS"
printf "\n"
tox run -e pypy3 -- $CCI_NODE_TESTS
no_output_timeout: 30m
- save_cache:
key: << parameters.cache_key_prefix >>1-{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
key: pypy-<< parameters.python_version >>-deps3-{{ checksum "tox.ini" }}-{{ checksum "pyproject.toml" }}
paths:
- "/home/circleci/project/.tox"
- "/root/project/.tox"
- "/usr/local/bin"
- "/usr/local/lib/python<< parameters.python_version >>/site-packages"

run_cpython_tests:
description: "Install Tox and run tests."
parameters:
python_version:
description: "Required. Python version as `major.minor`."
type: string
tox_envs:
description: "Required. Set of Tox environments to run on this node."
type: string
tox_parallel:
description: "Optional. Number of parallel workers spawned by Tox."
type: integer
default: 2
steps:
- setup_tests:
python_version: << parameters.python_version >>
cache_key_prefix: py<< parameters.python_version >>-deps
- run:
name: Run Tests
shell: /bin/bash -leo pipefail
environment:
TOX_PARALLEL_NO_SPINNER: 1
TOX_SHOW_OUTPUT: "True"
command: |
tox -p << parameters.tox_parallel >> -e << parameters.tox_envs >>
mkdir coverage
mv .coverage.* "coverage/.coverage.py<< parameters.python_version >>"
- teardown_tests:
python_version: << parameters.python_version >>
cache_key_prefix: py<< parameters.python_version >>-deps
- store_artifacts:
path: coverage
- store_test_results:
path: junit

jobs:
test-cpython-36:
docker:
- image: circleci/python:3.6-buster
steps:
- run_cpython_tests:
python_version: "3.6"
tox_envs: py36,py36-mypy,py36-lint,safety

test-cpython-37:
docker:
- image: circleci/python:3.7-buster
steps:
- run_cpython_tests:
python_version: "3.7"
tox_envs: py37,py37-mypy,py37-lint,safety

test-cpython-38:
test-pypy-38:
docker:
- image: circleci/python:3.8-buster
- image: pypy:3.8-slim-buster
parallelism: 8
steps:
- run_cpython_tests:
- run_pypy_tests:
python_version: "3.8"
tox_envs: py38,py38-mypy,py38-lint,safety

test-cpython-39:
test-pypy-39:
docker:
- image: circleci/python:3.9-buster
- image: pypy:3.9-slim-bookworm
parallelism: 8
steps:
- run_cpython_tests:
- run_pypy_tests:
python_version: "3.9"
tox_envs: py39,py39-mypy,py39-lint,format,safety

report-coverage:
test-pypy-310:
docker:
- image: circleci/python:3.9-buster
- image: pypy:3.10-slim-bookworm
parallelism: 8
steps:
- setup_tests:
python_version: "3.9"
cache_key_prefix: report-coverage-deps
- run:
name: Report Coverage
command: |
# Fetch the build numbers for this Workflow UUID
RECENT_BUILDS_URL="https://circleci.com/api/v1.1/project/github/basilisp-lang/basilisp/tree/$CIRCLE_BRANCH"
BUILD_NUMS=$(curl -H "Circle-Token: $CIRCLECI_API_TOKEN" "$RECENT_BUILDS_URL" | \
jq -r "map(select(.workflows.workflow_id == \"$CIRCLE_WORKFLOW_ID\")) | map(.build_num) | .[]")
echo "CircleCI build URL: $RECENT_BUILDS_URL"
echo "CircleCI build numbers: $(echo "$BUILD_NUMS" | tr '\n' ' ')"
# Fetch all of the artifacts for the build numbers
for build_num in $BUILD_NUMS
do
ARTIFACT_META_URL="https://circleci.com/api/v1.1/project/github/basilisp-lang/basilisp/$build_num/artifacts"
echo "Fetching artifacts for CircleCI build from: $ARTIFACT_META_URL"
ARTIFACT_URLS=$(curl -H "Circle-Token: $CIRCLECI_API_TOKEN" "$ARTIFACT_META_URL" | jq -r '.[].url')
if [ -n "$ARTIFACT_URLS" ]; then
echo "Found artifact URLs: $(echo "$ARTIFACT_URLS" | tr '\n' ' ')"
curl -L --remote-name-all $ARTIFACT_URLS
fi
done
tox -v -e coverage
- teardown_tests:
python_version: "3.8"
cache_key_prefix: report-coverage-deps

test-pypy:
docker:
- image: pypy:3.6-7-slim-buster
parallelism: 3
steps:
- checkout
- restore_cache:
key: pypy-deps2-{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
- run:
name: Install tox
command: |
pip install -U pip
pip install tox
- run:
name: Run Tests
command: |
CCI_NODE_TESTS=$(circleci tests glob "tests/**/*_test.*py" "tests/**/test_*.*py" | circleci tests split --split-by=timings)
printf "Test files:\n"
echo "$CCI_NODE_TESTS"
printf "\n"
tox -e pypy3 -- $CCI_NODE_TESTS
- save_cache:
key: pypy-deps2-{{ checksum "tox.ini" }}-{{ checksum "Pipfile.lock" }}
paths:
- "/root/project/.tox"
- "/usr/local/bin"
- "/usr/local/lib/python3.6/site-packages"
- store_test_results:
path: junit
- run_pypy_tests:
python_version: "3.10"

workflows:
version: 2
test:
jobs:
- test-cpython-36
- test-cpython-37
- test-cpython-38
- test-cpython-39
- test-pypy
- report-coverage:
requires:
- test-cpython-36
- test-cpython-37
- test-cpython-38
- test-cpython-39
- test-pypy-38
- test-pypy-39
- test-pypy-310
25 changes: 25 additions & 0 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release to PyPI

on:
release:
types: [ published ]

concurrency:
group: pypi-release

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ vars.PYTHON_VERSION }}
- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Validate Release Version
run: poetry version -s | grep -E "$(echo "$GITHUB_REF_NAME" | tr -d 'v')"
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }}
run: poetry publish --build
114 changes: 114 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Run tests

on:
pull_request:
types: [ opened, synchronize, reopened ]
push:
branches: [ main ]

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
run-tests:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest]
version: ['3.8', '3.9', '3.10', '3.11']
include:
- version: '3.8'
tox-env: py38,py38-mypy,py38-lint,safety
- version: '3.9'
tox-env: py39,py39-mypy,py39-lint,safety
- version: '3.10'
tox-env: py310,py310-mypy,py310-lint,safety
- version: '3.11'
tox-env: py311,py311-mypy,py311-lint,format,safety
- os: windows-latest
version: '3.11'
tox-env: py311,safety
- os: macos-latest
version: '3.11'
tox-env: py311,safety
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.version }}
- name: Cache dependencies
id: cache-deps
uses: actions/cache@v3
with:
path: |
.tox
~/.cache/pip
~/.cache/pypoetry
~/.local/share/pypoetry
key: ${{ runner.os }}-python-${{ matrix.version }}-poetry-${{ hashFiles('pyproject.toml', 'tox.ini') }}
- name: Install Poetry
if: steps.cache-deps.outputs.cache-hit != 'true' && ! startsWith (matrix.os, 'windows')
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install Poetry (Windows)
if: steps.cache-deps.outputs.cache-hit != 'true' && startsWith (matrix.os, 'windows')
shell: pwsh
run: |
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
- name: Install Tox
run: |
pip install -U pip
pip install tox
- name: Run tests
env:
TOX_PARALLEL_NO_SPINNER: 1
TOX_SHOW_OUTPUT: "True"
TOXENV: ${{ matrix.tox-env }}
run: |
tox run-parallel -p 2
mkdir coverage
mv .coverage.* "coverage/.coverage.py${{ matrix.version }}"
- name: Archive code coverage results
if: "startsWith (matrix.os, 'ubuntu')"
uses: actions/upload-artifact@v3
with:
name: code-coverage
path: coverage/.coverage.py*

report-coverage:
runs-on: ubuntu-latest
needs: run-tests
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ vars.PYTHON_VERSION }}
- name: Cache dependencies
id: cache-deps
uses: actions/cache@v3
with:
path: |
.tox
~/.cache/pip
~/.cache/pypoetry
~/.local/share/pypoetry
key: ${{ runner.os }}-python-coverage-poetry-${{ hashFiles('pyproject.toml', 'tox.ini') }}
- name: Install Poetry
if: steps.cache-deps.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install Tox
run: |
pip install -U pip
pip install tox
- name: Download code coverage
uses: actions/download-artifact@v3
with:
name: code-coverage
- name: Combine Coverage files from all supported Python versions
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: tox run -v -e coverage
- name: Report Combined Coverage
uses: coverallsapp/github-action@v2
with:
file: coverage.xml
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,6 @@ TODO
lintout.txt
lispcore.py
.idea/
.envrc
.envrc
poetry.lock
**/*.~undo-tree~
2 changes: 2 additions & 0 deletions .prospector.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
output-format: text

autodetect: false
strictness: medium
test-warnings: true
doc-warnings: false
Expand Down Expand Up @@ -40,5 +41,6 @@ pylint:
- no-else-raise
- no-else-return
- protected-access
- unnecessary-lambda-assignment
- unsubscriptable-object
- useless-import-alias
Loading

0 comments on commit 44f1b3a

Please sign in to comment.