Skip to content

Commit

Permalink
Static analysis workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dmzoneill committed May 30, 2024
1 parent fd07c0e commit f6f1b3a
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"threshold": 5,
"reporters": [
"consoleFull"
],
"ignore": [
"**/__snapshots__/**",
"**.html",
"**/tests/**"
],
"absolute": true
}
109 changes: 109 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
name: CICD

on:
pull_request:
push:
workflow_call:
inputs:
validate-all:
required: false
type: boolean
default: false

jobs:
static-analysis:
runs-on: ubuntu-latest
name: Static Analysis
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure linters
run : |-
# echo "disable=SC2086" > ~/.shellcheckrc
mkdir -vp .github/linters/config/
curl -o .github/linters/config/.jscpd.json https://raw.githubusercontent.com/RedHatInsights/insights-analytics-collector/main/.github/linters/.jscpd.json
- name: Lint
uses: github/super-linter@v4
env:
VALIDATE_GITHUB_ACTIONS: false
VALIDATE_ALL_CODEBASE: ${{ inputs.validate-all }}
VALIDATE_MARKDOWN: false
VALIDATE_PYTHON_MYPY: false
VALIDATE_PYTHON_FLAKE8: false
VALIDATE_NATURAL_LANGUAGE: false
DEFAULT_BRANCH: "main"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

unit-test:
name: Unit Tests
runs-on: ubuntu-latest
needs: static-analysis
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Pytest
run: |-
pip3 install pytest pytest-mock mock mocker django
pytest -s -v tests/
pypi-bump-version:
name: PyPI bump version
needs: unit-test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Filter
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- '*/**'
- 'setup.py'
- 'pyproject.toml'
- name: Bump
if: steps.changes.outputs.src == 'true'
run: |-
version=$(grep '__version__ = .*' setup.py | sed 's/__version__ = \"//' | sed 's/"//')
next=$(echo $version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
sed "s/$version/$next/" -i setup.py
- name: Push changes
if: steps.changes.outputs.src == 'true'
uses: mikeal/publish-to-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: 'main' #optional defaults to master

pypi-build-and-upload-package:
name: Pypi module build
needs: pypi-bump-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Build
run: |-
pip3 install trove-classifiers==2023.3.9 ptyprocess==0.6.0 msgpack==1.0.5 lockfile==0.12.2 distlib==0.3.4 tomlkit==0.11.4 tomli==2.0.1 shellingham==1.5.0.post1 rapidfuzz==2.13.7 pyrsistent==0.18.1 poetry-core==1.5.2 platformdirs==2.5.2 pkginfo==1.9.6 pexpect==4.8.0 packaging==21.3 jeepney==0.8.0 jaraco.classes==3.2.3 filelock==3.10.7 dulwich==0.21.3 crashtest==0.4.1 cachecontrol==0.12.11 virtualenv==20.15.1 SecretStorage==3.3.3 jsonschema==4.17.3 cleo==2.0.1 keyring==23.13.1 poetry-plugin-export==1.3.0 poetry==1.4.1
python3 -m pip install --upgrade build
python3 -m pip install --upgrade twine
python3 -m build
- name: Upload step
run: |-
# shellcheck disable=SC2035
printf "[pypi]\n username = __token__\n password = ${{ secrets.PYPI }}" > ~/.pypirc
# shellcheck disable=SC2035
python3 -m twine upload --verbose --non-interactive --config-file ~/.pypirc --repository pypi dist/*

0 comments on commit f6f1b3a

Please sign in to comment.