Skip to content

Commit

Permalink
chore: refactor the repository
Browse files Browse the repository at this point in the history
  • Loading branch information
breakthewall committed Oct 13, 2021
1 parent 3be6f15 commit d39aac0
Show file tree
Hide file tree
Showing 26 changed files with 314 additions and 431 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@ name: Check
on:

push:
branches: [ master, dev ]
paths-ignore:
- '**/RELEASE*'
- '**/README*'
- '**/LICENSE*'
- 'recipe'
- 'docs'
- '.gitignore'
- '.github'
- '!.github/workflows/check*'
- '**/_version.py'
branches: [ main, master, dev ]
paths:
- '**.py'
pull_request:
branches: [ master ]
branches: [ main, master ]

jobs:

Expand All @@ -39,4 +31,5 @@ jobs:
- name: Checking package
run: |
cd ci
make check-inconda
make check-buildenv env=check
conda run -n check make check
127 changes: 101 additions & 26 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,119 @@ name: Publish

on:
push:
tags: releases/[1-9]+.[0-9]+.[0-9]+
branches: [ stable ]
branches:
- stable
paths:
- '**.py'
- '!tests/**'

jobs:

Publish:
Conda-Build_Test:
runs-on: ubuntu-latest

env:
ANACONDA_TOKEN: ${{secrets.ANACONDA_TOKEN}}
ANACONDA_USER: ${{secrets.ANACONDA_USER}}

steps:
- uses: actions/checkout@v2
- uses: docker://continuumio/miniconda3

- name: Updating conda
run: conda update --all -y

- name: Installing make
run: conda install -y make

- name: Building package
run: |
sudo apt-get update
sudo apt-get -y install make
- name: Build conda package
run: |
cd ci
make conda-build
- name: Testing package
- name: Test conda package
run: |
cd ci
make conda-test
- name: Converting to other platforms
run: |
cd ci
make conda-convert
Tag:
needs: [Conda-Build_Test]
runs-on: ubuntu-latest
outputs: # Create variable usable from another job
new_tag: ${{ steps.tag_version.outputs.new_tag }}
steps:
## CREATE TAG/RELEASE
- uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v5.6
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: stable
tag_prefix:
- name: Create Release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
## UPDATE CHANGELOG
- uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- uses: actions/setup-ruby@v1
# with:
# ruby-version: '2.6' # Version range or exact version of a Ruby version to use, using semvers version range syntax.
- name: Generate CHANGELOG
env:
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gem install github_changelog_generator
github_changelog_generator -u brsynth -p rrparser --no-unreleased
- name: Update _version.py
env:
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.tag_version.outputs.new_tag }}
run: |
folder=`dirname $(find . -name _version.py)`
echo "__version__ = \"$TAG\"" > $folder/_version.py
- name: Commit files
run: |
git config --local user.email "$GITHUB_EMAIL"
git config --local user.name "$GITHUB_USERNAME"
git commit -m "doc(CHANGELOG): update" -a
env:
GITHUB_USERNAME: brsynth
GITHUB_EMAIL: joan.herisson@univ-evry.fr
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

- name: Uploading to anaconda
run: |
cd ci
make conda-publish
## UPDATE CONDA-FORGE FEEDSTOCK
Feedstock:
needs: [Tag]
runs-on: ubuntu-latest
steps:
- name: Checkout feedstock fork
uses: actions/checkout@v2
with:
repository: conda-forge/rrparser-feedstock
persist-credentials: false
fetch-depth: 0
- name: Update recipe
run: |
wget -O- https://github.com/brsynth/rrparser/archive/refs/tags/$VERSION.tar.gz | shasum -a 256 > sha.txt
sha=`python -c "f = open('sha.txt'); print(f.read().split()[0]); f.close()"`
rm -f sha.txt
sed -i -E "s/(\{% set version = \")[^>]+(\" %\})/\1$VERSION\2/" recipe/meta.yaml
sed -i -E "s/(sha256: )[^>]+/\1$sha/" recipe/meta.yaml
git config --local user.email "$GITHUB_EMAIL"
git config --local user.name "$GITHUB_USERNAME"
git commit -m "chore(meta.yml): update version" -a
env:
GITHUB_USERNAME: brsynth
GITHUB_EMAIL: joan.herisson@univ-evry.fr
VERSION: ${{ needs.tag.outputs.new_tag }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.FEEDSTOCK }}
push-to-fork: brsynth/rrparser-feedstock
19 changes: 6 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@ name: Test
on:

push:
branches: [ master, dev ]
paths-ignore:
- '**/RELEASE*'
- '**/README*'
- '**/LICENSE*'
- 'recipe'
- 'docs'
- '.gitignore'
- '.github'
- '!.github/workflows/test*'
- '**/_version.py'
branches: [ main, master, dev ]
paths:
- '**.py'
pull_request:
branches: [ master ]
branches: [ main, master ]

jobs:

Expand All @@ -39,4 +31,5 @@ jobs:
- name: Testing package
run: |
cd ci
make test-inconda
make test-buildenv env=test
conda run -n test make test
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changelog

## [2.4.1]
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# RRParser
# rrparser
Reaction Rules Parser
| Name | Downloads | Version | Platforms |
| --- | --- | --- | --- |
| [![Conda Recipe](https://img.shields.io/badge/recipe-rrparser-green.svg)](https://anaconda.org/conda-forge/rrparser) | [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/rrparser.svg)](https://anaconda.org/conda-forge/rrparser) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/rrparser.svg)](https://anaconda.org/conda-forge/rrparser) | [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/rrparser.svg)](https://anaconda.org/conda-forge/rrparser) |

[![Anaconda-Server Badge](https://anaconda.org/brsynth/rrparser/badges/latest_release_date.svg)](https://anaconda.org/brsynth/rrparser) ![Test](https://github.com/brsynth/RRulesParser/workflows/Test/badge.svg) [![Anaconda-Server Badge](https://anaconda.org/brsynth/rrparser/badges/version.svg)](https://anaconda.org/brsynth/rrparser)

Reaction Rules Parser. If no input reaction files is provided, retrieves the reaction rules from [RetroRules](https://retrorules.org).
## Description
*Reaction Rules Parser*. If no input reaction files is provided, retrieves the reaction rules from [RetroRules](https://retrorules.org).

## Input

Expand All @@ -17,7 +20,7 @@ Reaction Rules Parser. If no input reaction files is provided, retrieves the rea
## Install
### From Conda
```sh
[sudo] conda install -c brsynth rrparser
[sudo] conda install -c conda-forge rrparser
```

## Use
Expand All @@ -26,12 +29,14 @@ Reaction Rules Parser. If no input reaction files is provided, retrieves the rea
```python
from rrparser import parse_rules

outfile = parse_rules(<rules_file>,
<outfile>,
input_format=<'csv' | 'tsv'>,
rule_type=<'all' | 'retro' | 'forward'>,
diameters=<'2,4,6,8,10,12,14,16'>,
output_format=<'csv' | 'tsv'>)
outfile = parse_rules(
<rules_file>,
<outfile>,
input_format=<'csv' | 'tsv'>,
rule_type=<'all' | 'retro' | 'forward'>,
diameters=<'2,4,6,8,10,12,14,16'>,
output_format=<'csv' | 'tsv'>
)
```

If parameters from CLI have to be parsed, the function `build_args_parser` is available:
Expand Down Expand Up @@ -59,8 +64,7 @@ Test can be run with the following commands:

### Natively
```bash
cd tests
pytest -v
python -m pytest -v
```

# CI/CD
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion ci/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Jean-Loup Faulon's group & INRA
Copyright (c) 2020 Jean-Loup Faulon's group & INRAE
Copyright (c) 2020 University of Evry / Paris-Saclay

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
24 changes: 17 additions & 7 deletions ci/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
SHELL := /bin/bash
SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
PACKAGE = $(shell python ../setup.py --name)

include $(SELF_DIR)/.ci_env

include $(SELF_DIR)/.env
include $(SELF_DIR)/../extras/.env

# HELP
# This will output the help for each task
Expand Down Expand Up @@ -34,14 +35,20 @@ check: ## Test code with 'pytest', this is the fastest way to test the code
test: ## Test code with 'pytest', this is the fastest way to test the code
@$(MAKE_CMD) -f test.mk test args="$(args)"

%-inconda: ## Test conda package
%-buildenv: ## Test conda package
ifneq ($(strip $(env)),)
$(eval env=${PACKAGE}_$*)
endif
@$(MAKE_CMD) -f conda.mk check-environment-$* env=$(env)
@$(MAKE_CMD) -f conda.mk conda-run-env env=$(env) \
cmd="make -C .. $*" \
args="$(args)"
@$(MAKE_CMD) -f conda.mk build-environment-$* env=$(env)

# %-inconda: ## Test conda package
# ifneq ($(strip $(env)),)
# $(eval env=${PACKAGE}_$*)
# endif
# @$(MAKE_CMD) -f conda.mk check-environment-$* env=$(env)
# @$(MAKE_CMD) -f conda.mk conda-run-env env=$(env) \
# cmd="make -C .. $*" \
# args="$(args)"


conda-all: conda-build conda-test conda-convert conda-publish ## (default) Perform all conda process (build, test, convert, publish)
Expand All @@ -64,3 +71,6 @@ conda-check-recipe: ## Check conda recipe

conda-create-run_env: ## Make an conda environment to run program
@$(MAKE_CMD) -f conda.mk check-environment-test env=${PACKAGE}_test

doc-pdoc:
cd .. ; rm -rf chemlite/__pycache__ ; pdoc --force --html -o docs chemlite
Loading

0 comments on commit d39aac0

Please sign in to comment.