diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..7e2e9bc7 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,226 @@ +version: 2.1 + +executors: + python37: + docker: + - image: circleci/python:3.7.9 + resource_class: small + + python38: + docker: + - image: circleci/python:3.8.6 + resource_class: small + + python39: + docker: + - image: cimg/python:3.9.0 + resource_class: small + + with_browser: + docker: + - image: cimg/python:3.9.0-browsers + resource_class: small + + mac: + macos: + xcode: 12.1.0 + +commands: + + get_poetry_deps: + steps: + - run: + name: Checking Python version + command: | + python --version + python --version > /tmp/pythonversion + - restore_cache: + key: deps-00-{{ checksum "poetry.lock" }}-{{ checksum "/tmp/pythonversion" }}-{{ arch }} + - run: + name: Installing dependencies + command: | + poetry config --local virtualenvs.in-project true + poetry install --no-root --remove-untracked + - save_cache: + key: deps-00-{{ checksum "poetry.lock" }}-{{ checksum "/tmp/pythonversion" }}-{{ arch }} + paths: + - ~/project/.venv + + install_pa11y: + steps: + - restore_cache: + key: deps-00-pa11y + - run: + name: Install accessibility software (pa11y) + command: npm install pa11y pa11y-reporter-junit + - save_cache: + key: deps-00-pa11y + paths: + - ~/project/node_modules + + install_pyenv_poetry: + steps: + - run: + name: Checking Python version + command: | + echo "python: $JRNL_PYTHON_VERSION" + echo "$JRNL_PYTHON_VERSION" > /tmp/pythonversion + - restore_cache: + key: pyenv-00-{{ checksum "/tmp/pythonversion" }} + - run: + name: Updating path + command: echo 'export PATH="$HOME/.pyenv/bin:$HOME/.pyenv/shims:$PATH"' >> $BASH_ENV + - run: + name: Installing Pyenv + command: | + if [[ ! -d ~/.pyenv ]]; then + curl https://pyenv.run | bash + fi + - run: + name: Installing Python + command: | + pyenv install -s $JRNL_PYTHON_VERSION + pyenv global $JRNL_PYTHON_VERSION + - run: + name: Installing Poetry + command: pip install poetry + - save_cache: + key: pyenv-00-{{ checksum "/tmp/pythonversion" }} + paths: + - ~/.pyenv + + pytest: + steps: + - run: + name: Tests - Pytest + when: always + command: > + poetry run pytest + --junitxml=reports/pytest/results.xml + + behave: + steps: + - run: + name: Tests - Behave + when: always + command: > + poetry run behave + --no-skipped + --format progress2 + --junit + --junit-directory reports/behave + + lint: + steps: + - run: + name: Poetry Check + when: always + command: | + poetry --version + poetry check + - run: + name: Black Code Formatter + when: always + command: | + poetry run black --version + poetry run black --check --diff . + - run: + name: PyFlakes + when: always + command: | + poetry run pyflakes --version + poetry run pyflakes jrnl features tests + +aliases: + linux_test: &linux_test + steps: + - checkout + - get_poetry_deps + - run: poetry install + - pytest + - behave + - store_test_results: + path: reports + mac_test: &mac_test + steps: + - checkout + - install_pyenv_poetry + - get_poetry_deps + - run: poetry install + - pytest + - behave + - store_test_results: + path: reports + +jobs: + test_37_linux: + executor: python37 + <<: *linux_test + + test_38_linux: + executor: python38 + <<: *linux_test + + test_39_linux: + executor: python39 + <<: *linux_test + + test_37_mac: + executor: mac + environment: + JRNL_PYTHON_VERSION: 3.7.8 + <<: *mac_test + + test_38_mac: + executor: mac + environment: + JRNL_PYTHON_VERSION: 3.8.6 + <<: *mac_test + + test_39_mac: + executor: mac + environment: + JRNL_PYTHON_VERSION: 3.9.0 + <<: *mac_test + + linting: + executor: python39 + steps: + - checkout + - get_poetry_deps + - lint + + docs_a11y: + executor: with_browser + steps: + - checkout + - get_poetry_deps + - install_pa11y + - run: + name: Starting mkdocs server + command: poetry run mkdocs serve + background: true + - run: poetry run .circleci/pa11y.sh + - store_test_results: + path: reports + +workflows: + version: 2 + main: + jobs: + - docs_a11y: + name: Documentation site (jrnl.sh) accessibility + - linting: + name: Linting and Formatting + - test_37_linux: + name: Python 3.7 - Linux + - test_38_linux: + name: Python 3.8 - Linux + - test_39_linux: + name: Python 3.9 - Linux + - test_37_mac: + name: Python 3.7 - Mac + - test_38_mac: + name: Python 3.8 - Mac + - test_39_mac: + name: Python 3.9 - Mac diff --git a/.circleci/pa11y.sh b/.circleci/pa11y.sh new file mode 100755 index 00000000..b3d5abc3 --- /dev/null +++ b/.circleci/pa11y.sh @@ -0,0 +1,19 @@ +#! /bin/bash +set +e + +reports_dir="reports/pa11y" +site_url="http://127.0.0.1:8000" +exit_code=0 + +mkdocs build +mkdir -p "$reports_dir" + +printf -- 'scanning: /\n' +./node_modules/.bin/pa11y "$site_url" --reporter junit > "$reports_dir/root.xml" || exit_code=2 + +for file in $(xq '.urlset.url[].loc' site/sitemap.xml -r | sed -r 's!https://jrnl.sh/(.*?)/$!\1!'); do + printf -- 'scanning: /%s\n' "$file" + ./node_modules/.bin/pa11y "$site_url/$file" --reporter junit > "$reports_dir/$file.xml" || exit_code=2 +done + +exit $exit_code diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..ea79d0f2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,192 @@ +dist: xenial # required for Python >= 3.7 +os: linux +language: python + +cache: + pip: true + directories: + - $HOME/virtualenv + +git: + depth: false + autocrlf: false + +before_install: + - date + +install: + - pip install --upgrade poetry + - poetry config virtualenvs.in-project true + - poetry config --list + - poetry install + - poetry run python --version + +script: + - poetry run pytest + - poetry run behave + +aliases: + test_mac: &test_mac + os: osx + language: shell + osx_image: xcode11.2 + cache: + directories: + - $HOME/.pyenv/versions + - $HOME/Library/Caches/pypoetry + before_install: + - brew upgrade pyenv + - eval "$(pyenv init -)" + - pyenv install -s $JRNL_PYTHON_VERSION + - pyenv global $JRNL_PYTHON_VERSION + - pip install --upgrade pip + - pip --version + test_windows: &test_windows + os: windows + language: shell + env: &env_windows + PATH: /c/Python37:/c/Python37/Scripts:/c/Python38:/c/Python38/Scripts:/c/Python39:/c/Python39/Scripts:/c/Python310:/c/Python310/Scripts:$PATH + PYTHONIOENCODING: UTF-8 + cache: + directories: + - /c/Python37 + - /c/Python38 + - /c/Python39 + - /c/Python310 + - /c/ProgramData/chocolatey/lib + - /c/ProgramData/chocolatey/bin + - /c/Users/travis/AppData/Local/pypoetry/Cache + before_install: + - choco install python --version $JRNL_PYTHON_VERSION + - python -m pip install --upgrade pip + - pip --version + +jobs: + fast_finish: true + allow_failures: + - name: Python 3.10 on Windows + - name: Python 3.10 on Linux + - name: Python 3.10 on MacOS + - python: nightly + + include: + - name: Misc Linting + python: 3.8 + script: + - poetry --version + - poetry check + - black --version + - black --check --diff . + - pyflakes --version + - pyflakes . + + # Python 3.7 Tests + - name: Python 3.7 on Linux + python: 3.7 + - <<: *test_mac + name: Python 3.7 on MacOS + python: 3.7 + env: + JRNL_PYTHON_VERSION: 3.7.7 + - <<: *test_windows + name: Python 3.7 on Windows + python: 3.7 + env: + <<: *env_windows + JRNL_PYTHON_VERSION: 3.7.7 + + # Python 3.8 Tests + - name: Python 3.8 on Linux + python: 3.8 + - <<: *test_mac + name: Python 3.8 on MacOS + python: 3.8 + env: + JRNL_PYTHON_VERSION: 3.8.2 + - <<: *test_windows + name: Python 3.8 on Windows + python: 3.8 + env: + <<: *env_windows + JRNL_PYTHON_VERSION: 3.8.2 + + # Python 3.9 Tests + - name: Python 3.9 on Linux + python: 3.9-dev + - <<: *test_mac + name: Python 3.9 on MacOS + env: + JRNL_PYTHON_VERSION: 3.9.0 + - <<: *test_windows + name: Python 3.9 on Windows + python: 3.9 + env: + <<: *env_windows + JRNL_PYTHON_VERSION: 3.9.0 + + # Python 3.10 Tests + - name: Python 3.10 on Linux + before_install: + - pip install toml + - python .build/allow_all_python_version.py + python: 3.10-dev + - <<: *test_mac + name: Python 3.10 on MacOS + before_install: + - brew upgrade pyenv + - eval "$(pyenv init -)" + - pyenv install -s $JRNL_PYTHON_VERSION + - pyenv global $JRNL_PYTHON_VERSION + - pip install --upgrade pip + - pip --version + - pip install toml + - python .build/allow_all_python_version.py + env: + JRNL_PYTHON_VERSION: 3.10-dev + - <<: *test_windows + name: Python 3.10 on Windows + before_install: + - choco install python --pre + - python --version + - python -m pip install --upgrade pip + - pip --version + - pip install toml + - python .build/allow_all_python_version.py + python: 3.10 + env: + <<: *env_windows + JRNL_PYTHON_VERSION: 3.10.0-a1 + + # ... and beyond! + - name: Python nightly on Linux + before_install: + - python .build/allow_all_python_version.py + python: nightly + + # Specialty tests + - name: Python 3.7 on Linux, not UTC + python: 3.7 + env: + TZ: America/Edmonton + + - stage: Deploy + if: tag IS present + before_deploy: + - poetry build + script: + - echo "Deployment starting..." + deploy: + - provider: script + script: poetry publish + skip_cleanup: true + on: + all_branches: true + + # Changelog for Unreleased changes + - stage: Update Changelog + if: (tag IS present) OR (branch = develop AND type NOT IN (pull_request)) + install: + - echo 'Skipping installation step' + script: + - ./.build/generate_changelog.sh +