Skip to content

Commit

Permalink
feat: use Kosmorrolib (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
Deuchnord authored and Jérôme Deuchnord committed May 15, 2021
1 parent b46f628 commit 87206d7
Show file tree
Hide file tree
Showing 73 changed files with 1,438 additions and 2,584 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/black.yml
@@ -0,0 +1,19 @@
name: Code style

on:
push:
branches: [main, features]
pull_request:
branches: [main, features]

jobs:
lint:
runs-on: ubuntu-latest

name: Code Style
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: psf/black@20.8b1
66 changes: 0 additions & 66 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/i18n.yml
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Check i18n
run: |
pipenv run python setup.py extract_messages --output-file=/tmp/kosmorro-messages.pot > /dev/null
diff=$(diff kosmorrolib/locales/messages.pot /tmp/kosmorro-messages.pot | grep '^>')
diff=$(diff _kosmorro/locales/messages.pot /tmp/kosmorro-messages.pot | grep '^>')
n=$(echo "$diff" | grep -v '> "POT-Creation-Date: ' | wc -l)
if [ "$(echo "$diff" | grep -E '^"Generated-By: Babel' | wc -l)" -eq "1" ]; then
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/pylint.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/unit-tests.yml
@@ -1,42 +0,0 @@
name: Unit tests

on:
push:
branches: [master, features]
pull_request:
branches: [master, features]

jobs:
unit-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-18.04
- ubuntu-20.04
- macos-10.15
- macos-11.0
python-version:
- '3.7'
- '3.8'
- '3.9'

name: Unit tests (Python ${{ matrix.python-version }} on ${{ matrix.os }})
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade pip pipenv
pipenv sync -d
- name: Unit tests
env:
COVERALLS_PRO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make test
pipenv run coveralls --service=github
50 changes: 29 additions & 21 deletions .scripts/tests-e2e.sh
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION=$(grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' kosmorrolib/version.py)
VERSION=$(grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' _kosmorro/__version__.py)
PYTHON_BIN=$(command -v python)
PIP_BIN=$(command -v pip)

Expand Down Expand Up @@ -68,6 +68,8 @@ function assertFailure() {
echo -n '.'
}

mkdir -p $HOME/kosmorro/export

echo
echo "==== RUNNING E2E TESTS ===="
echo
Expand All @@ -76,36 +78,42 @@ echo
assertSuccess "make build"
assertSuccess "$PIP_BIN install dist/kosmorro-$VERSION.tar.gz" "CI"

assertSuccess kosmorro
assertSuccess "kosmorro -h"
assertSuccess "kosmorro -d 2020-01-27"
assertFailure "kosmorro -d yolo-yo-lo"
assertFailure "kosmorro -d 2020-13-32"
assertFailure "kosmorro --date=1789-05-05"
assertFailure "kosmorro --date=3000-01-01"
assertSuccess "kosmorro --date='+3y 5m3d'"
assertSuccess "kosmorro --date='-1y3d'"
assertFailure "kosmorro --date='+3d4m"
assertFailure "kosmorro -date='3y'"
assertSuccess "kosmorro --latitude=50.5876 --longitude=3.0624"
assertSuccess "kosmorro --latitude=50.5876 --longitude=3.0624 -d 2020-01-27"
assertSuccess "kosmorro --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --timezone=1"
assertSuccess "kosmorro --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --timezone=-1"
assertSuccess "kosmorro --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=json"
assertFailure "kosmorro --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf"
KOSMORRO_COMMAND="kosmorro --debug"

assertSuccess "$KOSMORRO_COMMAND"
assertSuccess "$KOSMORRO_COMMAND -h"
assertSuccess "$KOSMORRO_COMMAND -d 2020-01-27"
assertFailure "$KOSMORRO_COMMAND -d yolo-yo-lo"
assertFailure "$KOSMORRO_COMMAND -d 2020-13-32"
assertFailure "$KOSMORRO_COMMAND --date=1789-05-05"
assertFailure "$KOSMORRO_COMMAND --date=3000-01-01"
assertSuccess "$KOSMORRO_COMMAND --date='+3y 5m3d'"
assertSuccess "$KOSMORRO_COMMAND --date='-1y3d'"
assertFailure "$KOSMORRO_COMMAND --date='+3d4m"
assertFailure "$KOSMORRO_COMMAND -date='3y'"
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624"
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27"
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --timezone=1"
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --timezone=-1"
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=json"
assertFailure "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf"

# Environment variables
assertSuccess "LATITUDE=50.5876 LONGITUDE=3.0624 TIMEZONE=1 kosmorro -d 2020-01-27"
assertSuccess "LATITUDE=50.5876 LONGITUDE=3.0624 TIMEZONE=-1 kosmorro -d 2020-01-27"

# Missing dependencies, should fail
assertFailure "kosmorro --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf -o /tmp/document.pdf"
assertFailure "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf -o $HOME/kosmorro/export/document.pdf"
assertFailure "ls $HOME/kosmorro/export/document.pdf"

assertSuccess "sudo apt-get install -y texlive texlive-latex-extra" "CI"

# Dependencies installed, should not fail
assertSuccess "kosmorro --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf -o /tmp/document.pdf"
assertSuccess "kosmorro --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf -o /tmp/document.pdf --no-graph"
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf -o $HOME/kosmorro/export/document.pdf"
assertSuccess "ls $HOME/kosmorro/export/document.pdf"

assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf -o $HOME/kosmorro/export/document-no-graph.pdf --no-graph"
assertSuccess "ls $HOME/kosmorro/export/document-no-graph.pdf"

# man page
assertSuccess "man --pager=cat kosmorro"
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
@@ -1,2 +1,2 @@
recursive-include kosmorrolib/locales *
recursive-include kosmorrolib/assets *
recursive-include _kosmorro/locales *
recursive-include _kosmorro/assets *
17 changes: 11 additions & 6 deletions Makefile
@@ -1,5 +1,7 @@
.PHONY: test
black:
pipenv run black kosmorro _kosmorro setup.py

.PHONY: test
test:
export LC_ALL=C.UTF-8; \
export LANG=C.UTF-8; \
Expand All @@ -12,7 +14,7 @@ build: manpages
python3 setup.py sdist bdist_wheel

messages:
pipenv run python setup.py extract_messages --output-file=kosmorrolib/locales/messages.pot
pipenv run python setup.py extract_messages --output-file=_kosmorro/locales/messages.pot

manpages:
ronn --roff manpage/kosmorro.1.md
Expand All @@ -32,10 +34,10 @@ release: env
@echo -e "\e[1mCreating release with version number \e[36m$$RELEASE_NUMBER\e[0m"
@echo

sed "s/^VERSION =.*/VERSION = '$$RELEASE_NUMBER'/g" kosmorrolib/version.py > version.py
mv version.py kosmorrolib/version.py
sed "s/^VERSION =.*/VERSION = '$$RELEASE_NUMBER'/g" _kosmorro/version.py > version.py
mv version.py _kosmorro/version.py

pipenv run python setup.py extract_messages --output-file=kosmorrolib/locales/messages.pot > /dev/null
pipenv run python setup.py extract_messages --output-file=_kosmorro/locales/messages.pot > /dev/null

conventional-changelog -p angular -i CHANGELOG.md -s
sed "0,/\\[\\]/s/\\[\\]/[v$$RELEASE_NUMBER]/g" CHANGELOG.md > /tmp/CHANGELOG.md
Expand All @@ -47,7 +49,7 @@ release: env
@echo -e "Please review the changes, then invoke \e[33mmake finish-release\e[39m."

finish-release: env
git add CHANGELOG.md kosmorrolib/version.py kosmorrolib/locales/messages.pot
git add CHANGELOG.md _kosmorro/version.py _kosmorro/locales/messages.pot
git commit -m "build: bump version $$RELEASE_NUMBER"
git tag "v$$RELEASE_NUMBER"
git checkout features
Expand All @@ -57,3 +59,6 @@ finish-release: env
@echo
@echo -e "\e[1mVersion \e[36m$$RELEASE_NUMBER\e[39m successfully tagged!"
@echo -e "Invoke \e[33mgit push origin master features v$$RELEASE_NUMBER\e[39m to finish."

clean:
rm -rf build dist kosmorro.egg-info manpage/kosmorro.{1,7}{,.html}
11 changes: 5 additions & 6 deletions Pipfile
Expand Up @@ -4,18 +4,17 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pylintfileheader = "*"
pylint = "*"
babel = "*"
coveralls = "*"
parameterized = "*"
black = "*"

[packages]
skyfield = ">=1.32.0,<2.0.0"
tabulate = "*"
numpy = ">=1.17.0,<2.0.0"
termcolor = "*"
kosmorrolib = ">=0.11.0,<0.12.0"
python-dateutil = "*"

[requires]
python_version = "3"

[pipenv]
allow_prereleases = true

0 comments on commit 87206d7

Please sign in to comment.