Skip to content
This repository was archived by the owner on Jun 9, 2024. It is now read-only.

Commit 3dacf66

Browse files
authored
Move Toolkit in the new repo (#1)
1 parent 50603a3 commit 3dacf66

49 files changed

Lines changed: 2606 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/commands.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Slash Command Dispatch
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
slash-command-dispatch:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/github-script@v3
12+
id: get-pr
13+
with:
14+
script: |
15+
const request = {
16+
owner: context.repo.owner,
17+
repo: context.repo.repo,
18+
pull_number: context.issue.number
19+
}
20+
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`)
21+
try {
22+
const result = await github.pulls.get(request)
23+
return result.data
24+
} catch (err) {
25+
core.setFailed(`Request failed with error ${err}`)
26+
}
27+
- name: Slash Command Dispatch
28+
uses: peter-evans/slash-command-dispatch@v2
29+
with:
30+
token: ${{ secrets.BOT_TOKEN }}
31+
reaction-token: ${{ secrets.BOT_TOKEN }}
32+
permission: write
33+
dispatch-type: workflow
34+
event-type-suffix: ""
35+
commands: |
36+
deploy-toolkit
37+
static-args: |
38+
comment-id=${{ github.event.comment.id }}
39+
event-number=${{ github.event.issue.number }}
40+
ref=${{ fromJSON(steps.get-pr.outputs.result).head.ref }}
41+
- name: Edit comment with error message
42+
if: steps.scd.outputs.error-message
43+
uses: peter-evans/create-or-update-comment@v1
44+
with:
45+
comment-id: ${{ github.event.comment.id }}
46+
body: |
47+
> ${{ steps.scd.outputs.error-message }}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Toolkit Library Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'toolkit/**/*'
9+
workflow_dispatch:
10+
inputs:
11+
comment-id:
12+
description: 'The comment-id of the slash command'
13+
required: true
14+
event-number:
15+
description: 'The event-id of the slash command'
16+
required: true
17+
18+
jobs:
19+
publish-library:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
with:
24+
persist-credentials: false
25+
ref: ${{ github.ref }}
26+
- name: Install poetry
27+
run: pip install poetry
28+
- name: Set up Python
29+
uses: actions/setup-python@v2
30+
with:
31+
python-version: 3.9.5
32+
- name: Metadata
33+
id: metadata
34+
run: echo "::set-output name=commit::$(git rev-parse HEAD)"
35+
- name: Find Release Comment
36+
uses: peter-evans/find-comment@v1
37+
id: find_comment
38+
if: ${{ github.ref != 'refs/heads/main' }}
39+
with:
40+
token: ${{ secrets.BOT_TOKEN }}
41+
issue-number: ${{ github.event.inputs.event-number }}
42+
comment-author: pythonitaliabot
43+
body-includes: "Pre-release"
44+
- name: Create or update comment
45+
id: initial-comment
46+
uses: peter-evans/create-or-update-comment@v1
47+
if: ${{ github.ref != 'refs/heads/main' }}
48+
with:
49+
token: ${{ secrets.BOT_TOKEN }}
50+
comment-id: ${{ steps.find_comment.outputs.comment-id }}
51+
issue-number: ${{ github.event.inputs.event-number }}
52+
body: |
53+
# Pre-release
54+
:wave:
55+
56+
Releasing commit [${{ steps.metadata.outputs.commit }}] to PyPi as pre-release! :package:
57+
edit-mode: replace
58+
- name: Update version
59+
if: ${{ github.ref == 'refs/heads/main' }}
60+
run: poetry version patch
61+
- name: Update to pre-release version
62+
if: ${{ github.ref != 'refs/heads/main' }}
63+
run: |
64+
poetry version patch
65+
poetry version $(poetry version -s)-dev.$(date '+%s')
66+
- name: Build & Publish
67+
id: release
68+
env:
69+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
70+
run: |
71+
poetry publish --username __token__ --build
72+
echo "::set-output name=version::$(poetry version -s)"
73+
- name: Commit version
74+
if: ${{ github.ref == 'refs/heads/main' }}
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
77+
run: |
78+
git remote set-url origin https://${{ secrets.BOT_TOKEN }}@github.com/${{ github.repository }}
79+
80+
git config user.name "Python Italia [bot]"
81+
git config user.email "noreply@python.it"
82+
83+
git add pyproject.toml
84+
git commit -m "🔨 Publish Toolkit v$(poetry version -s) [skip ci]"
85+
git push
86+
- name: Create or update comment
87+
uses: peter-evans/create-or-update-comment@v1
88+
if: ${{ github.ref != 'refs/heads/main' }}
89+
with:
90+
token: ${{ secrets.BOT_TOKEN }}
91+
comment-id: ${{ steps.initial-comment.outputs.comment-id }}
92+
issue-number: ${{ github.event.inputs.event-number }}
93+
body: |
94+
# Pre-release
95+
:wave:
96+
97+
Pre-release **${{ steps.release.outputs.version }}** [${{ steps.metadata.outputs.commit }}] has been released on PyPi! :rocket:
98+
You can try it by doing:
99+
100+
```shell
101+
poetry add pythonit-toolkit==${{ steps.release.outputs.version }}
102+
```
103+
edit-mode: replace

.github/workflows/tests.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
working-directory: ./
15+
services:
16+
postgres:
17+
image: postgres:11.10
18+
env:
19+
POSTGRES_USER: postgres
20+
POSTGRES_PASSWORD: postgres
21+
POSTGRES_DB: postgres
22+
ports:
23+
- 5432/tcp
24+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: actions/setup-python@v2
28+
with:
29+
python-version: "3.9.5"
30+
- run: pip install poetry
31+
- name: Set Poetry config
32+
run: poetry config virtualenvs.path ~/.virtualenvs
33+
- name: Cache Poetry
34+
uses: actions/cache@v1
35+
id: cache
36+
with:
37+
path: ~/.virtualenvs
38+
key: poetry-toolkit-${{ hashFiles('**/poetry.lock') }}-v2
39+
- name: Install deps
40+
run: poetry install
41+
- name: Unit tests
42+
run: poetry run task test
43+
env:
44+
DATABASE_URL: postgresql+asyncpg://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
45+
IDENTITY_SECRET: 'secret'
46+
PASTAPORTO_SECRET: 'secret'
47+
SERVICE_TO_SERVICE_SECRET: 'secret'
48+
PASTAPORTO_ACTION_SECRET: 'secret'

.gitignore

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
.DS_Store
2+
# Byte-compiled / optimized / DLL files
3+
__pycache__/
4+
*.py[cod]
5+
*$py.class
6+
7+
# C extensions
8+
*.so
9+
10+
# Distribution / packaging
11+
.Python
12+
env/
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
parts/
22+
sdist/
23+
var/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
cov.xml
47+
*,cover
48+
.hypothesis/
49+
.pytest_cache
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Django stuff:
56+
*.log
57+
local_settings.py
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# IPython Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# dotenv
82+
.env
83+
84+
# virtualenv
85+
venv/
86+
ENV/
87+
88+
# Spyder project settings
89+
.spyderproject
90+
91+
# Rope project settings
92+
.ropeproject
93+
94+
*.sqlite3
95+
96+
# Ignore vscode configuration
97+
.vscode/
98+
99+
# Ignore pycharm configuration
100+
.idea/
101+
102+
backend/media/
103+
104+
node_modules/
105+
106+
pretix-conf/
107+
pretix-data/
108+
secrets.auto.tfvars
109+
110+
.vercel
111+
**/.next/**
112+
113+
*.generated.ts
114+
**/helpers/types.ts
115+
116+
**/coverage/**
117+

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Pastaporto
2+
3+
Python IT Toolkit library

0 commit comments

Comments
 (0)