Skip to content

Commit

Permalink
feat: Add package publishing workflow (#99)
Browse files Browse the repository at this point in the history
Also adds github ci workflow and removes circleci config
as part of #100
  • Loading branch information
pkulkark committed Feb 1, 2023
1 parent 72705b6 commit 11d3db0
Show file tree
Hide file tree
Showing 23 changed files with 585 additions and 110 deletions.
78 changes: 0 additions & 78 deletions .circleci/config.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Python CI
on:
pull_request: {}
workflow_dispatch: {}
push:
branches: [master]

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

jobs:
commitlint:
uses: openedx/.github/.github/workflows/commitlint.yml@master

run_tests:
name: tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: [py38-django32, quality]

steps:
- uses: actions/checkout@v3
- name: setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox
34 changes: 34 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: pypi-publish

on:
release:
types: [published]
workflow_dispatch: {}

jobs:
publish-package:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3

- name: setup python
uses: actions/setup-python@v3
with:
python-version: 3.8

- name: Install pip
run: pip install pip

- name: Install Dependencies
run: pip install setuptools wheel

- name: Build package
run: python setup.py sdist bdist_wheel

- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PUBLISH_TOKEN }}
47 changes: 36 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.DEFAULT_GOAL := help

FIREFOX_VERSION := "94.0.1"
FIREFOX_VERSION := "67.0"
FIREFOX_LINUX_ARCH := $(shell uname -m)

help: ## display this help message
Expand All @@ -24,19 +24,43 @@ clean: ## remove generated byte code, coverage reports, and build artifacts
rm -fr dist/
rm -fr *.egg-info

# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
PIP_COMPILE = pip-compile --upgrade $(PIP_COMPILE_OPTS)

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -qr requirements/pip-tools.txt
# Make sure to compile files after any other files they include!
$(PIP_COMPILE) --allow-unsafe -o requirements/pip.txt requirements/pip.in
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
pip install -qr requirements/pip-tools.txt
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in

quality: ## check coding style with pycodestyle and pylint
pycodestyle poll --max-line-length=120
pylint poll

node_requirements: ## Install requirements for handlebar templates i18n extraction
npm install

python_requirements: ## install development environment requirements
pip install -r requirements.txt --exists-action w
pip install -r requirements-dev.txt --exists-action w
python_requirements: install_linux_dev_firefox ## install development environment requirements
pip install wheel
pip install -r requirements/base.txt --exists-action w
pip install -r requirements/dev.txt --exists-action w
ifeq ($(VIRTUAL_ENV),)
cd ./src/xblock-sdk && \
pip install -r requirements/base.txt && \
pip install -r requirements/test.txt
pip install -r requirements/base.txt && \
pip install -r requirements/test.txt
else
cd $(VIRTUAL_ENV)/src/xblock-sdk && \
pip install -r requirements/base.txt && \
pip install -r requirements/test.txt
endif
pip uninstall -y selenium
pip install selenium==3.4.1
pip install -e .

requirements: node_requirements python_requirements ## install development environment requirements
Expand All @@ -52,15 +76,16 @@ install_linux_dev_firefox: ## Downloads custom version of firefox for Selenium i
--output .firefox/firefox.tar.bz2

cd .firefox && tar -xvjf firefox.tar.bz2
cd .geckodriver && wget https://github.com/mozilla/geckodriver/releases/download/v0.15.0/geckodriver-v0.15.0-linux64.tar.gz
cd .geckodriver && tar -xzf geckodriver-v0.15.0-linux64.tar.gz
cd .geckodriver && wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz
cd .geckodriver && tar -xzf geckodriver-v0.26.0-linux64.tar.gz

linux_dev_test: ## Run tests in development environment to use custom firefox
PATH=.firefox/firefox/:.geckodriver/:$(PATH) make test
mkdir -p var
PATH=.firefox/firefox/:.geckodriver/:$(PATH) xvfb-run python run_tests.py

test: ## run tests in the current virtualenv
mkdir -p var # for var/workbench.log
python run_tests.py --with-coverage --cover-package=poll
mkdir -p var
DJANGO_SETTINGS_MODULE=workbench.settings pytest

selfcheck: ## check that the Makefile is well-formed
@echo "The Makefile is well-formed."
Expand Down
2 changes: 1 addition & 1 deletion poll/poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ def vote(self, data, suffix=''):

# Make sure the answer values are sane.
for key, value in data.items():
if value not in answers.keys():
if value not in answers:
result['success'] = False
result['errors'].append(
self.ugettext(
Expand Down
2 changes: 1 addition & 1 deletion poll/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
# http://django-statici18n.readthedocs.io/en/latest/settings.html

with open(os.path.join(BASE_DIR, 'poll/translations/config.yaml'), 'r') as locale_config_file:
locale_config = yaml.load(locale_config_file)
locale_config = yaml.load(locale_config_file, Loader=yaml.SafeLoader)

LANGUAGES = [
(code, code,)
Expand Down
5 changes: 4 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ disable=
unused-argument,
useless-object-inheritance,
import-outside-toplevel,
super-with-arguments
super-with-arguments,
consider-using-f-string,
unspecified-encoding,
redundant-u-string-prefix

[SIMILARITIES]
min-similarity-lines=8
5 changes: 2 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Internationalization and Localization requirements
-e 'git://github.com/edx/xblock-sdk.git@v0.1.6#egg=xblock-sdk==v0.1.6 ; python_version == "2.7"'
-e 'git://github.com/edx/xblock-sdk.git#egg=xblock-sdk ; python_version > "2.7"'
-e 'git+https://github.com/openedx/xblock-sdk.git@v0.1.6#egg=xblock-sdk==v0.1.6 ; python_version == "2.7"'
-e 'git+https://github.com/openedx/xblock-sdk.git@0.4.0#egg=xblock-sdk==0.4.0 ; python_version > "2.7"'

Django~=1.11; python_version == '2.7'
Django>=2.2, <3.3; python_version > '2.7'
Expand All @@ -15,4 +15,3 @@ edx-i18n-tools==0.5.0
pycodestyle==2.4.0
pylint
tox==3.14.0
django-nose==1.4.6
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
markdown
-e git://github.com/edx/xblock-utils.git@2.1.0#egg=xblock-utils
-e git+https://github.com/openedx/xblock-utils.git@2.2.0#egg=xblock-utils
ddt
mock
django-nose==1.4.6
bleach==3.1.5
-e .
8 changes: 8 additions & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Core requirements for using this application
-c constraints.txt

markdown
-e git+https://github.com/openedx/xblock-utils.git@2.2.0#egg=xblock-utils
ddt
mock
bleach==5.0.0
58 changes: 58 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# make upgrade
#
-e git+https://github.com/openedx/xblock-utils.git@2.2.0#egg=xblock-utils
# via -r requirements/base.in
appdirs==1.4.4
# via fs
bleach==5.0.0
# via -r requirements/base.in
ddt==1.6.0
# via -r requirements/base.in
fs==2.4.16
# via xblock
importlib-metadata==6.0.0
# via markdown
lxml==4.9.2
# via xblock
mako==1.2.4
# via xblock-utils
markdown==3.4.1
# via -r requirements/base.in
markupsafe==2.1.2
# via
# mako
# xblock
mock==5.0.1
# via -r requirements/base.in
python-dateutil==2.8.2
# via xblock
pytz==2022.7.1
# via xblock
pyyaml==6.0
# via xblock
simplejson==3.18.1
# via xblock-utils
six==1.16.0
# via
# bleach
# fs
# python-dateutil
web-fragments==2.0.0
# via
# xblock
# xblock-utils
webencodings==0.5.1
# via bleach
webob==1.8.7
# via xblock
xblock==1.6.1
# via xblock-utils
zipp==3.11.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# setuptools
9 changes: 9 additions & 0 deletions requirements/ci.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Requirements for running tests in CI

-c constraints.txt

codecov # Code coverage reporting
tox # Virtualenv management for tests
tox-battery # Makes tox aware of requirements file changes
pycodestyle==2.4.0
pylint
Loading

0 comments on commit 11d3db0

Please sign in to comment.