Skip to content

Commit

Permalink
chore: bump more-itertool down to ^8.0.0, update actions & deps
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnakumar committed Oct 30, 2023
1 parent 76efb4a commit 8cf609d
Show file tree
Hide file tree
Showing 14 changed files with 5,656 additions and 5,794 deletions.
6 changes: 3 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"presets": ["@babel/preset-env", "@babel/preset-react"],
"env": {
"production": {
"plugins": ["@babel/plugin-proposal-object-rest-spread", "styled-jsx/babel", "@babel/syntax-dynamic-import"]
"plugins": ["@babel/plugin-transform-object-rest-spread", "styled-jsx/babel", "@babel/syntax-dynamic-import"]
},
"development": {
"plugins": ["@babel/plugin-proposal-object-rest-spread", "styled-jsx/babel", "@babel/syntax-dynamic-import"]
"plugins": ["@babel/plugin-transform-object-rest-spread", "styled-jsx/babel", "@babel/syntax-dynamic-import"]
},
"test": {
"plugins": ["@babel/plugin-proposal-object-rest-spread", "styled-jsx/babel-test", "@babel/syntax-dynamic-import"]
"plugins": ["@babel/plugin-transform-object-rest-spread", "styled-jsx/babel-test", "@babel/syntax-dynamic-import"]
}
}
}
23 changes: 23 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.vscode export-ignore
.github export-ignore
src export-ignore
tests export-ignore
_validate_init.py export-ignore
.babelrc export-ignore
.eslintignore export-ignore
.eslintrc export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.npmignore export-ignore
.prettierrc export-ignore
.Rbuildignore export-ignore
codecov.yml export-ignore
CONTRIBUTING.md export-ignore
lgtm.yml export-ignore
MANIFEST.in export-ignore
package-lock.json export-ignore
poetry.lock export-ignore
pytest.ini export-ignore
TODO.md export-ignore
webpack.config.js export-ignore
webpack.serve.config.js export-ignore
26 changes: 25 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,35 @@ name: "CodeQL"
on:
push:
branches: [ master ]
paths-ignore:
- '.github/**'
- '.gitattributes'
- '.vscode/**'
- 'CHANGELOG.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'README.md'
- 'TODO.md'
- 'lgtm.yml'
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
paths-ignore:
- '.github/**'
- '.gitattributes'
- '.vscode/**'
- 'CHANGELOG.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'README.md'
- 'TODO.md'
- 'lgtm.yml'
schedule:
- cron: '23 14 * * 4'
- cron: '30 9 1-7 * 1'

concurrency:
group: code-ql-${{ github.head_ref }}-1
cancel-in-progress: true

jobs:
analyze:
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/extract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!python3
from pathlib import Path
import re
import sys
from typing import Any


def extract_changelog_content(changelog: Any, version):

if Path(changelog).exists():
changelog_text: str = Path(changelog).read_text()
elif isinstance(changelog, bytes):
changelog_text = changelog.decode("utf-8")
elif isinstance(changelog, str):
changelog_text = changelog
else:
raise TypeError("Invalid type for changelog")

# Extract the header for the changelog
header = re.search(r"([#\s]{2}Changelog)([\s\S]*?(?=[#]{2}))", changelog_text, re.MULTILINE)

# Extract the relevant version marked changes
version_extract_pattern = r"(^[#]{2}.*\[" + re.escape(version) + r"\][\s\S]*?(?=^[#]{2}\s))"
version_extract = re.search(version_extract_pattern, changelog_text, re.MULTILINE)
if header and version_extract:
return f"{header.group()}\n{version_extract.group()}"
else:
return None


# Read the changelog file
with open("CHANGELOG.md", "r") as file:
changelog_text = file.read()

if __name__ == "__main__":
# Extract content for the specified version
changelog_text = sys.argv[1]
input_version = sys.argv[2]
output_content = extract_changelog_content(changelog_text, input_version)

if output_content:
print(output_content)
else:
print(f"Changelog for version {input_version} not found.")
exit(1)
48 changes: 0 additions & 48 deletions .github/workflows/python-publish.yml

This file was deleted.

114 changes: 114 additions & 0 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Release Python Package

on:
workflow_dispatch:

concurrency:
group: release-${{ github.head_ref }}-1
cancel-in-progress: true

jobs:
release:
# Only run from the default branch
if: github.ref_name == github.event.repository.default_branch
runs-on: ubuntu-latest
env:
PYTHON_VERSION: "3.10"
POETRY_VERSION: "1.6.1"
NODE_VERSION: '18'
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write

steps:
- uses: actions/checkout@v4.1.1
with:
token: ${{ secrets.GIT_TOKEN }}
fetch-depth: 2
- name: Check if there is a parent commit
id: check-parent-commit
run: |
echo "sha=$(git rev-parse --verify --quiet HEAD^)" | tee -a "$GITHUB_OUTPUT"
- uses: actions/setup-node@v4.0.0
with:
node-version: '${{ env.NODE_VERSION }}'
registry-url: https://registry.npmjs.org/
- name: Set up Python
uses: actions/setup-python@v4.7.1
with:
python-version: '${{ env.PYTHON_VERSION }}'
- name: Install poetry
uses: Gr1N/setup-poetry@v8
with:
poetry-version: '${{ env.POETRY_VERSION }}'
- name: Cache poetry
id: cached-poetry-dependencies
uses: actions/cache@v3.3.2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('poetry.lock') }}-python-${{ env.PYTHON_VERSION }}

- id: check-poetry-version-is-valid
run: poetry --version

- name: Install dependencies
run: poetry install

- name: Detect and tag new version
if: steps.check-parent-commit.outputs.sha != ''
id: get-version
run: |
VERSION="$(bash -o pipefail -c "poetry version | awk '{ print \$2 }'")"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION=v${VERSION}" >> $GITHUB_OUTPUT
echo "RELEASE_INFO='Release for Package Version v${VERSION}'" >> $GITHUB_OUTPUT
- name: Create release branch and build python package
if: steps.get-version.outputs.RELEASE_VERSION != ''
id: create-release-branch-and-build
run: |
git config --global user.name "peakmaster"
export rbranch="release/${{ steps.get-version.outputs.RELEASE_VERSION }}"
git branch $rbranch
sed -i '/dash_extensions\/*/d' .gitignore
poetry run npm install || echo "Ignore npm install error"
poetry run npm run build
git add .
git commit -am "chore: create release for ${{ steps.get-version.outputs.RELEASE_VERSION }}"
git push origin $rbranch --force
echo "RELEASE_BRANCH=$rbranch" >> $GITHUB_OUTPUT
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Read CHANGELOG.md and use it as body of new release
if: steps.create-release-branch-and-build.outputs.RELEASE_BRANCH != ''
id: read-changelog
shell: bash
run: |
r=$(python3 ./.github/workflows/extract.py ./CHANGELOG.md ${{ steps.get-version.outputs.VERSION }}) # <--- Read Changelog.md
r="${r//'%'/'%25'}" # Multiline escape sequences for %
r="${r//$'\n'/'%0A'}" # Multiline escape sequences for '\n'
r="${r//$'\r'/'%0D'}" # Multiline escape sequences for '\r'
echo "CHANGELOG=$r" >> $GITHUB_OUTPUT
- name: Create Release
if: steps.create-release-branch-and-build.outputs.RELEASE_BRANCH != ''
id: create-release
uses: ncipollo/release-action@v1.13.0
with:
allowUpdates: true
body: ${{ steps.read-changelog.outputs.CHANGELOG }}
tag: ${{ steps.get-version.outputs.RELEASE_VERSION }}
name: ${{ steps.get-version.outputs.RELEASE_INFO }}
token: ${{ secrets.GIT_TOKEN }}
makeLatest: true
replacesArtifacts: true
removeArtifacts: true
commit: ${{ steps.create-release-branch-and-build.outputs.RELEASE_BRANCH }}
67 changes: 45 additions & 22 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,74 @@ name: Unit tests
on:
push:
branches: [ master ]
paths-ignore:
- '.github/**'
- '.gitattributes'
- '.vscode/**'
- 'CHANGELOG.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'README.md'
- 'TODO.md'
- 'lgtm.yml'
pull_request:
branches: [ master ]
paths-ignore:
- '.github/**'
- '.gitattributes'
- '.vscode/**'
- 'CHANGELOG.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'README.md'
- 'TODO.md'
- 'lgtm.yml'

concurrency:
group: unit-tests-${{ github.head_ref }}-1
cancel-in-progress: true

jobs:
build:
test:
name: Unit-Tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- { python: "3.10", poetry: "1.6.1", node: '18' }
- { python: "3.11", poetry: "1.6.1", node: '18' }
env:
TEST_CYCLE_BREAKER_ALLOWED_ERRORS: 7
steps:
- uses: actions/checkout@v3
- uses: nanasess/setup-chromedriver@v2
- uses: actions/setup-node@v3
- uses: actions/checkout@v4.1.1
with:
token: ${{ secrets.GIT_TOKEN }}
- uses: nanasess/setup-chromedriver@v2.2.0
- uses: actions/setup-node@v4.0.0
with:
node-version: 16
node-version: '${{ matrix.node }}'
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v4.7.1
with:
python-version: '3.10'
python-version: '${{ matrix.python }}'
- name: Install poetry
uses: Gr1N/setup-poetry@v8
with:
poetry-version: "1.3.2"
poetry-version: '${{ matrix.poetry }}'
- name: Cache poetry
id: cached-poetry-dependencies
uses: actions/cache@v3
uses: actions/cache@v3.3.2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-python-${{ matrix.python-version }}
key: ${{ runner.os }}-poetry-${{ matrix.poetry }}-${{ hashFiles('poetry.lock') }}-python-${{ matrix.python }}
- run: poetry --version
- name: Install dependencies
run: poetry install
run: poetry install --all-extras
- name: Build components
run: |
poetry run npm install | echo "Ignore npm install error"
poetry run npm run build_no_r
- name: Test with pytest
run: |
poetry run pytest --cov=dash_extensions --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov-report=xml tests
- name: Upload pytest test results
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
poetry run pytest --cov=dash_extensions tests
Loading

0 comments on commit 8cf609d

Please sign in to comment.