Skip to content

Commit 25a39ea

Browse files
authored
Set up the repository and move stuff from apify-sdk and apify-client here (#2)
1 parent 4282d7f commit 25a39ea

29 files changed

+1399
-1
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
end_of_line = lf
10+
11+
[Makefile]
12+
indent_style = tab
13+
14+
[{*.yaml, *.yml}]
15+
indent_size = 2

.flake8

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[flake8]
2+
filename =
3+
./scripts/*.py,
4+
./src/*.py,
5+
./tests/*.py
6+
per-file-ignores =
7+
scripts/*: D
8+
tests/*: D
9+
10+
# Google docstring convention + D204 & D401
11+
docstring-convention = all
12+
ignore =
13+
D100
14+
D104
15+
D203
16+
D213
17+
D215
18+
D406
19+
D407
20+
D408
21+
D409
22+
D413
23+
U101
24+
25+
max_line_length = 150
26+
unused-arguments-ignore-overload-functions = True
27+
unused-arguments-ignore-stub-functions = True
28+
pytest-fixture-no-parentheses = True
29+
pytest-mark-no-parentheses = True
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint and type checks
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
lint_and_type_checks:
8+
name: Lint and type checks
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.8", "3.9", "3.10", "3.11"]
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install dependencies
24+
run: make install-dev
25+
26+
- name: Run lint
27+
run: make lint
28+
29+
- name: Run type checks
30+
run: make type-check

.github/workflows/pr_toolkit.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# For more info see: https://github.com/apify/pull-request-toolkit-action/
2+
name: Apify PR toolkit
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- master
8+
types: ['opened', 'reopened', 'synchronize', 'labeled', 'unlabeled', 'edited', 'ready_for_review'] # The first 3 are default.
9+
10+
concurrency: # This is to make sure that it's executed only for the most recent changes of PR.
11+
group: ${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
apify-pr-toolkit:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: run pull-request-toolkit action
19+
uses: apify/pull-request-toolkit-action@main
20+
with:
21+
repo-token: ${{ secrets.GITHUB_TOKEN }}
22+
org-token: ${{ secrets.PULL_REQUEST_TOOLKIT_ACTION_GITHUB_TOKEN }}
23+
zenhub-token: ${{ secrets.PULL_REQUEST_TOOLKIT_ACTION_ZENHUB_TOKEN }}

.github/workflows/release.yaml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Check & Release
2+
3+
on:
4+
# Push to master will publish a beta version
5+
push:
6+
branches:
7+
- master
8+
tags-ignore:
9+
- '**'
10+
# A release via GitHub releases will publish a stable version
11+
release:
12+
types: [published]
13+
# Workflow dispatch will publish whatever you choose
14+
workflow_dispatch:
15+
inputs:
16+
release_type:
17+
description: 'Release type'
18+
required: true
19+
type: choice
20+
default: 'alpha'
21+
options:
22+
- 'alpha'
23+
- 'beta'
24+
- 'final'
25+
26+
jobs:
27+
lint_and_type_checks:
28+
name: Run lint and type_checks
29+
uses: ./.github/workflows/lint_and_type_checks.yaml
30+
31+
unit_tests:
32+
name: Run unit tests
33+
uses: ./.github/workflows/unit_tests.yaml
34+
35+
publish_to_pypi:
36+
name: Publish to PyPI
37+
needs: [lint_and_type_checks, unit_tests]
38+
runs-on: ubuntu-latest
39+
permissions:
40+
contents: write
41+
id-token: write
42+
environment:
43+
name: pypi
44+
url: https://pypi.org/p/apify-client
45+
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@v3
49+
50+
- name: Set up Python
51+
uses: actions/setup-python@v4
52+
with:
53+
python-version: 3.8
54+
55+
- name: Install dependencies
56+
run: make install-dev
57+
58+
- # Determine if this is a prerelease or latest release
59+
name: Determine release type
60+
id: get-release-type
61+
run: |
62+
if [ ${{ github.event_name }} = release ]; then
63+
release_type="final"
64+
elif [ ${{ github.event_name }} = push ]; then
65+
release_type="beta"
66+
elif [ ${{ github.event_name }} = workflow_dispatch ]; then
67+
release_type=${{ github.event.inputs.release_type }}
68+
fi
69+
70+
if [ ${release_type} = final ]; then
71+
docker_image_tag="latest"
72+
elif [ ${release_type} = beta ]; then
73+
docker_image_tag="beta"
74+
else
75+
docker_image_tag=""
76+
fi
77+
78+
echo "release_type=${release_type}" >> $GITHUB_OUTPUT
79+
echo "docker_image_tag=${docker_image_tag}" >> $GITHUB_OUTPUT
80+
81+
- # Check whether the released version is listed in CHANGELOG.md
82+
name: Check whether the released version is listed in the changelog
83+
if: steps.get-release-type.outputs.release_type != 'alpha'
84+
run: make check-changelog-entry
85+
86+
- # Check version consistency and increment pre-release version number for prereleases (must be the last step before build)
87+
name: Bump pre-release version
88+
if: steps.get-release-type.outputs.release_type != 'final'
89+
run: python ./scripts/update_version_for_prerelease.py ${{ steps.get-release-type.outputs.release_type }}
90+
91+
- # Build a source distribution and a python3-only wheel
92+
name: Build distribution files
93+
run: make build
94+
95+
- # Check whether the package description will render correctly on PyPI
96+
name: Check package rendering on PyPI
97+
run: make twine-check
98+
99+
- # Publish package to PyPI using their official GitHub action
100+
name: Publish package to PyPI
101+
uses: pypa/gh-action-pypi-publish@release/v1
102+
103+
- # Tag the current commit with the version tag if this is not made from the release event (releases are tagged with the release process)
104+
name: Tag Version
105+
if: github.event_name != 'release'
106+
run: |
107+
git_tag=v`python ./scripts/print_current_package_version.py`
108+
git tag $git_tag
109+
git push origin $git_tag
110+
111+
- # Upload the build artifacts to the release
112+
name: Upload the build artifacts to release
113+
if: github.event_name == 'release'
114+
run: gh release upload ${{ github.ref_name }} dist/*
115+
env:
116+
GH_TOKEN: ${{ github.token }}

.github/workflows/run_checks.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Code quality checks
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
lint_and_type_checks:
8+
name: Run lint and type checks
9+
uses: ./.github/workflows/lint_and_type_checks.yaml
10+
11+
unit_tests:
12+
name: Run unit tests
13+
needs: [lint_and_type_checks]
14+
uses: ./.github/workflows/unit_tests.yaml

.github/workflows/unit_tests.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Unit tests
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
unit_tests:
8+
name: Run unit tests
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, windows-latest]
12+
python-version: ["3.8", "3.9", "3.10", "3.11"]
13+
runs-on: ${{ matrix.os }}
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: make install-dev
26+
27+
- name: Run unit tests
28+
run: make unit-tests

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
__pycache__
2+
.mypy_cache
3+
.pytest_cache
4+
5+
.venv
6+
.direnv
7+
.envrc
8+
.python-version
9+
10+
*.egg-info/
11+
*.egg
12+
dist/
13+
build/
14+
15+
.vscode
16+
.idea
17+
.DS_Store

.isort.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[isort]
2+
include_trailing_comma = True
3+
line_length = 150
4+
use_parentheses = True
5+
multi_line_output = 3
6+
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
7+
known_first_party = apify_shared

.pre-commit-config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: lint
5+
name: "Lint codebase"
6+
entry: "make lint"
7+
language: system
8+
pass_filenames: false
9+
10+
- id: type-check
11+
name: "Type-check codebase"
12+
entry: "make type-check"
13+
language: system
14+
pass_filenames: false
15+
16+
- id: unit-tests
17+
name: "Run unit tests"
18+
entry: "make unit-tests"
19+
language: system
20+
pass_filenames: false
21+
22+
- id: check-changelog
23+
name: "Check whether current version is mentioned in changelog"
24+
entry: "make check-changelog-entry"
25+
language: system
26+
pass_filenames: false

0 commit comments

Comments
 (0)