Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(scripts) #44

Merged
merged 30 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions .github/workflows/always.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: percebus/github-actions-common/.github/actions/checkout@main
with:
ssh-private-key: ${{ secrets.SSH_KEY_PRIVATE }}

- name: setup python @ ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
architecture: ${{ env.ARCHITECTURE }}
python-version: ${{ env.PYTHON_VERSION }}

# includes poetry install
- name: scripts/setup.ba.sh
run: bash scripts/setup.ba.sh
- name: scripts/prepare.ba.sh
run: bash scripts/prepare.ba.sh

- name: poetry install
run: poetry install
run: bash _scripts/poetry/install.ba.sh ci

- name: pypyr lock
run: pypyr lock freeze=True
run: pipx run -- pypyr lock freeze=True

# TODO commit back upgraded requirements

Expand Down Expand Up @@ -67,23 +68,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: percebus/github-actions-common/.github/actions/checkout@main
with:
ssh-private-key: ${{ secrets.SSH_KEY_PRIVATE }}

- name: setup python @ ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
architecture: ${{ env.ARCHITECTURE }}
python-version: ${{ env.PYTHON_VERSION }}
- name: pip install
run: bash scripts/install.ba.sh

- uses: percebus/github-actions-node/.github/actions/node_setup@main
- uses: percebus/github-actions-npm/.github/actions/npm_install@main

- name: scripts/prepare.ba.sh
run: bash scripts/prepare.ba.sh

- name: poetry install
run: bash _scripts/poetry/install.ba.sh ci

- name: pypyr lint
run: pypyr lint stats=True
run: pipx run -- pypyr lint stats=True

- name: pypyr test
run: pypyr ci lint=False
run: pipx run -- pypyr ci lint=False

- name: Publish test-results.xml Summary
if: always()
Expand Down Expand Up @@ -145,30 +152,41 @@ jobs:
# echo "JOB_NAME: ${{ env.JOB_NAME }}"

- uses: percebus/github-actions-common/.github/actions/checkout@main
with:
ssh-private-key: ${{ secrets.SSH_KEY_PRIVATE }}

- name: setup python @ ${{ matrix.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
architecture: ${{ matrix.ARCHITECTURE }}
python-version: ${{ matrix.PYTHON_VERSION }}
- name: pip install
run: bash scripts/install.ba.sh

- uses: percebus/github-actions-node/.github/actions/node_setup@main
- uses: percebus/github-actions-npm/.github/actions/npm_install@main

- name: scripts/prepare.ba.sh
run: bash scripts/prepare.ba.sh

- name: poetry install
run: bash _scripts/poetry/install.ba.sh ci

# FIXME prettier fails on windows
# Because of EOL differences
# Thus, we disabled 'npm'
- name: pypyr test
run: pypyr ci npm=False
run: pipx run -- pypyr ci npm=False

docker_compose:
name: docker compose
needs: verify
runs-on: ubuntu-latest
steps:
- uses: percebus/github-actions-common/.github/actions/checkout@main
with:
ssh-private-key: ${{ secrets.SSH_KEY_PRIVATE }}

- name: scripts/prepare.ba.sh
run: bash scripts/prepare.ba.sh 'pre-docker'

- name: docker compose up
run: docker compose up --abort-on-container-exit
Expand All @@ -193,6 +211,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: percebus/github-actions-common/.github/actions/checkout@main
with:
ssh-private-key: ${{ secrets.SSH_KEY_PRIVATE }}

- name: scripts/prepare.ba.sh
run: bash scripts/prepare.ba.sh

- name: "docker build: ${{ matrix.DOCKER_TARGET }}"
run: |
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
tmp/
test-results.xml

# commons/scripts
repos/
_scripts/


########################
### Python.gitignore ### SRC: https://github.com/github/gitignore/blob/main/Python.gitignore
########################
Expand Down
4 changes: 4 additions & 0 deletions .gitlinks
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SRC: https://github.com/chronoxor/gil?tab=readme-ov-file#root-gitlinks-file

# commons/scripts
commons repos/commons https://github.com/percebus/commons.git main
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ FROM base AS project
WORKDIR /usr/app
COPY . .
RUN ls -la
RUN bash scripts/bash/clean.ba.sh
RUN bash _scripts/bash/clean.ba.sh


FROM project AS dev
RUN bash scripts/install.ba.sh
RUN bash _scripts/install.ba.sh

FROM dev AS test
RUN pypyr ci npm=False stats=False
RUN pipx run -- pypyr ci npm=False stats=False

# TODO use light image. alpine?
FROM project AS release
RUN bash scripts/pip/install.ba.sh 'release'
RUN bash _scripts/pip/install.ba.sh 'release'
CMD [ "python", "src/problems/" ]
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@
"pip:upgrade:pip": "python -m pip install --upgrade pip",
"prepip:upgrade:requirements": "npm run pip:upgrade:pip",
"pip:upgrade:requirements": "python -m pip install --upgrade --requirement requirements.upgrade.txt",
"pipx:setup": "bash scripts/pipx/setup.ba.sh",
"prepipx:install": "npm run pip:upgrade:requirements",
"pipx:install": "bash _scripts/pipx/install.ba.sh",
"flake8": "flake8 src --benchmark --statistics",
"prettier": "prettier .",
"prettier:check": "npm run prettier -- --check",
"prettier:write": "npm run prettier -- --write",
"pre-commit:install": "pre-commit install",
"dockerlint": "dockerlint Dockerfile",
"setup": "npm run pip:upgrade:requirements && npm run pipx:setup && npm run pre-commit:install",
"setup": "npm run pipx:install && npm run pre-commit:install",
"lint": "npm run dockerlint && npm run prettier:check",
"style": "npm run prettier:write",
"poststyle": "npm run lint",
"docker:build": "docker build .",
"docker:build:test": "npm run docker:build -- --target test",
"predocker:build": "npm run dockerlint",
"docker:compose:up": "docker compose up",
"test": "pypyr ci",
"test": "pipx run -- pypyr test",
"test:docker": "npm run docker:build:test",
"semantic-release": "semantic-release",
"tag": "npm run semantic-release"
Expand Down
4 changes: 2 additions & 2 deletions pipelines/clean.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ context_parser: pypyr.parser.keyvaluepairs
steps:
- name: pypyr.steps.echo
in:
echoMe: "= pypyr clean =================================================="
echoMe: = pypyr clean ==================================================

- name: pypyr.steps.call
in:
Expand All @@ -12,4 +12,4 @@ steps:
pyclean:
- name: pypyr.steps.shell
in:
cmd: "pipx run pyclean ."
cmd: pipx run -- pyclean .
20 changes: 10 additions & 10 deletions pipelines/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ context_parser: pypyr.parser.keyvaluepairs
steps:
- name: pypyr.steps.echo
in:
echoMe: "= pypyr lint ================================================"
echoMe: = pypyr lint ================================================
- name: pypyr.steps.default
comment: set default values for optional cli inputs
in:
Expand All @@ -16,7 +16,7 @@ steps:
run: "{stats}"
in:
set:
PYLINT_CLI_ARGS: "--report y"
PYLINT_CLI_ARGS: --report y

- name: pypyr.steps.call
run: "{npm}"
Expand All @@ -36,47 +36,47 @@ steps:
dockerlint:
- name: pypyr.steps.echo
in:
echoMe: "=== dockerlint =============================================="
echoMe: === dockerlint ==============================================
- name: pypyr.steps.shell
in:
cmd: "npm run dockerlint"
cmd: npm run dockerlint

prettier:
- name: pypyr.steps.echo
in:
echoMe: "=== npx prettier --check ===================================="
echoMe: === npx prettier --check ====================================
- name: pypyr.steps.shell
in:
cmd: "npx prettier {path} --check"

ruff:
- name: pypyr.steps.echo
in:
echoMe: "=== ruff check =============================================="
echoMe: === ruff check ==============================================
- name: pypyr.steps.shell
in:
cmd: ruff check {path}
cmd: "ruff check {path}"

pyright:
- name: pypyr.steps.echo
in:
echoMe: "=== pyright ================================================="
echoMe: === pyright =================================================
- name: pypyr.steps.shell
in:
cmd: pyright --warnings

mypy:
- name: pypyr.steps.echo
in:
echoMe: "=== mypy ==================================================="
echoMe: === mypy ===================================================
- name: pypyr.steps.shell
in:
cmd: mypy src

pylint:
- name: pypyr.steps.echo
in:
echoMe: "=== pylint =================================================="
echoMe: === pylint ==================================================
- name: pypyr.steps.shell
in:
cmd: "pylint {PYLINT_CLI_ARGS} src"
12 changes: 6 additions & 6 deletions pipelines/lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ context_parser: pypyr.parser.keyvaluepairs
steps:
- name: pypyr.steps.echo
in:
echoMe: "= pypyr lock ==============================================="
echoMe: = pypyr lock ===============================================
- name: pypyr.steps.default
comment: set default values for optional cli inputs
in:
Expand All @@ -19,26 +19,26 @@ steps:
poetry_lock:
- name: pypyr.steps.echo
in:
echoMe: "= poetry lock ============================================="
echoMe: = poetry lock ==============================================
- name: pypyr.steps.shell
in:
cmd: poetry lock

poetry_export:
- name: pypyr.steps.echo
in:
echoMe: "= poetry export requirements(cli|dev|main).txt ============"
echoMe: = poetry export requirements(cli|dev|main).txt ============
- name: pypyr.steps.shell
foreach: ["cli", "main", "dev"]
in:
cmd: poetry export --no-interaction --format requirements.txt --output requirements.poetry.{i}.txt --only {i}
cmd: "poetry export --no-interaction --format requirements.txt --output requirements.poetry.{i}.txt --only {i}"

pip_freeze:
- name: pypyr.steps.echo
run: "{freeze}"
in:
echoMe: "= pip freeze =============================================="
echoMe: = pip freeze ==============================================
- name: pypyr.steps.shell
run: "{freeze}"
in:
cmd: bash scripts/pip/freeze.ba.sh
cmd: bash _scripts/pip/freeze.ba.sh
12 changes: 6 additions & 6 deletions pipelines/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ context_parser: pypyr.parser.keyvaluepairs
steps:
- name: pypyr.steps.echo
in:
echoMe: "= pypyr qa ==================================================="
echoMe: = pypyr qa ===================================================
- name: pypyr.steps.default
comment: set default values for optional cli inputs
in:
Expand All @@ -20,24 +20,24 @@ steps:
- name: pypyr.steps.shell
run: "{clean}"
in:
cmd: "pypyr clean path={path}"
cmd: "pipx run -- pypyr clean path={path}"

- name: pypyr.steps.shell
run: "{style}"
in:
cmd: "pypyr style path={path} npm={npm} lint=False"
cmd: "pipx run -- pypyr style path={path} npm={npm} lint=False"

- name: pypyr.steps.shell
run: "{lint}"
in:
cmd: "pypyr lint path={path} npm={npm} stats={stats}"
cmd: "pipx run -- pypyr lint path={path} npm={npm} stats={stats}"

- name: pypyr.steps.shell
run: "{test}"
in:
cmd: "pypyr test path={path} lint=False stats={stats}"
cmd: "pipx run -- pypyr test path={path} lint=False stats={stats}"

- name: pypyr.steps.shell
run: "{integration}"
in:
cmd: "pypyr test path={path} integration=True stats=False lint=False"
cmd: "pipx run -- pypyr test path={path} integration=True stats=False lint=False"
Loading
Loading