-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add simple tasks and config files (#1)
* feat: add simple tasks and config files * feat: wip multiple destinations config * ci: wip add test workflows * build base docker * push to ghrc.io * run checker in it * chore: use glob patterns in export section * ci: remove env section; due not available in inputs * ci: fix repo name in docker name * ci: try to use env for image name * ci: switch to copypaste in image tag * ci: set permissions: packages: write, remove default write * ci: abb multistage docker base and testenv version * ci: disable default linux/arm64 build * wip: plugins design * chore: add version to checker config * ci: update ci with checker and manytask * style: apply black * fix: use ${{ variables }} syntax in a config * feat: add structure field in the config * feat: wip add checker template * chore(deps): ignore patch updates * chore: style fixes and some config fixes * feat: fix validation for tester * feat: MVP working pipeline * ci: build test without pushing * ci: fix artifact_name * ci: use outputs of docker/build-push-action * ci: fix docker image loading by docker guide * ci: fix Check private repo run * ci: fix run checkr in docker, use cmd without quotes * ci: fix checker testing workspace dir * chore: add hotfix with checker req * chore: add working testing pipeline * chore: move checker to separate repo * fix: install checker from git --------- Co-authored-by: Konstantin Chernyshev <[email protected]>
- Loading branch information
1 parent
125d08d
commit 3b06cfd
Showing
38 changed files
with
656 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
version: 1 | ||
|
||
|
||
# can be overwritten in .task.yml for individual tasks | ||
structure: | ||
ignore_patterns: ["checker", ".git", ".idea", ".vscode", "__pycache__", ".venv", ".*_cache", "*.pyc"] | ||
# public patterns: include in export, overwrite during testing | ||
public_patterns: ["README.md", ".lecture", ".gitlab-ci-students.yml", "requirements.txt", "tools", "pyproject.toml", ".gitignore", "test_public.py", "conftest.py"] | ||
# private patterns: exclude from export, overwrite during testing | ||
private_patterns: [".*", "test_private.py"] | ||
|
||
|
||
# default values for all tasks, can be overwritten in .task.yml params: | ||
default_params: | ||
run_typechecking: true | ||
run_linting: true | ||
run_testing: true | ||
|
||
partially_scored: false | ||
|
||
run_merge_request_checks: true | ||
require_merge_request_approval: false | ||
search_for_merge_request_score: false | ||
|
||
timeout: 60 # seconds | ||
coverage: null # 0..1, null for no measurement | ||
|
||
|
||
# settings for export command, uses .deadlines.yml and `params` and each task params (in .task.yml) | ||
export: | ||
destination: https://gitlab.manytask.org/test/public-test-repo | ||
default_branch: main | ||
commit_message: "chore(auto): export new tasks" | ||
templates: search # search or create | ||
|
||
|
||
# manytask settings, used in scores export (testing) | ||
manytask: | ||
url: https://test.manytask.org | ||
course: "test" | ||
|
||
|
||
# settings for Tester, uses .checker.yml and `params` and each task params (in .task.yml) | ||
testing: | ||
changes_detection: branch_name # branch_name, commit_message, last_commit_changes, files_changed | ||
|
||
search_plugins: ["tools/plugins"] | ||
|
||
# run once per repo | ||
global_pipeline: | ||
- name: "List temp dir" | ||
fail: fast # fast, after_all, never | ||
run: "run_script" | ||
args: | ||
origin: ${{ TEMP_DIR }} | ||
script: "ls -la ." | ||
|
||
- name: "Fail never" | ||
fail: never # fast, after_all, never | ||
run: "run_script" | ||
args: | ||
origin: ${{ TEMP_DIR }} | ||
script: "false" | ||
|
||
- name: "Greeting" | ||
fail: fast # fast, after_all, never | ||
run: "run_script" | ||
args: | ||
origin: ${{ TEMP_DIR }} | ||
script: "echo ${{ TEMP_DIR }}" | ||
|
||
# run once per task | ||
tasks_pipeline: | ||
- name: "Check forbidden regexps" | ||
fail: fast # fast, after_all, never | ||
run: "check_regexps" | ||
args: | ||
origin: "${{ TEMP_DIR }}/${{ TASK_SUB_PATH }}" | ||
patterns: ["**/*.py"] | ||
regexps: ["exit(0)"] | ||
|
||
- name: "Run linter" | ||
run_if: ${{ run_linting }} | ||
fail: after_all # fast, after_all, never | ||
run: "run_script" | ||
args: | ||
origin: ${{ TEMP_DIR }} | ||
script: "python -m ruff --config=pyproject.toml ${{ TASK_SUB_PATH }}" | ||
|
||
- name: "Run typechecker" | ||
run_if: ${{ run_typechecking }} | ||
fail: after_all # fast, after_all, never | ||
run: "run_script" | ||
args: | ||
origin: ${{ TEMP_DIR }} | ||
script: "python -m mypy --config-file=pyproject.toml ${{ TASK_SUB_PATH }}" | ||
|
||
- name: "Collect tests" | ||
run_if: ${{ run_testing }} | ||
fail: after_all # fast, after_all, never | ||
run: "run_script" | ||
args: | ||
origin: ${{ TEMP_DIR }} | ||
script: "python -m pytest --tb=no -qq --collect-only ${{ TASK_SUB_PATH }}" | ||
timeout: ${{ timeout }} | ||
# isolate: true | ||
|
||
- name: "Run tests" | ||
run_if: ${{ run_testing }} | ||
fail: after_all # fast, after_all, never | ||
run: "run_pytest" | ||
register_score: "test_score" | ||
args: | ||
origin: ${{ TEMP_DIR }} | ||
target: ${{ TASK_SUB_PATH }} | ||
timeout: ${{ timeout }} | ||
coverage: ${{ coverage }} | ||
partially_scored: ${{ partially_scored }} | ||
# isolate: true | ||
|
||
# - name: "Run Merge Request checks" | ||
# run_if: ${{ run_merge_request_checks }} | ||
# fail: after_all # fast, after_all, never | ||
# run: "check_gitlab_merge_request" | ||
# args: | ||
# token: ${{ GITLAB_API_TOKEN }} | ||
# task_dir: ${{ TASK_SUB_PATH }} | ||
# repo_url: ${{ REPOSITORY_URL }} | ||
# requre_approval: ${{ require_merge_request_approval }} | ||
# search_for_score: ${{ search_for_merge_request_score }} | ||
|
||
# will run once per task only if task_pipeline NOT failed | ||
report_pipeline: | ||
# - name: "Search score in MR" | ||
# run_if: ${{ search_for_merge_request_score }} | ||
# run: "search_score_in_gitlab_merge_request" | ||
# register_score: "final_score" | ||
# args: | ||
# token: ${{ GITLAB_API_TOKEN }} | ||
# repo_url: ${{ REPOSITORY_URL }} | ||
# mr_label: ${{ TASK_NAME }} | ||
# score_by: "https://gitlab.manytask.org/test" | ||
|
||
- name: "Aggregate score" | ||
run_if: ${{ !search_for_merge_request_score }} | ||
run: "aggregate" | ||
register_score: "final_score" | ||
args: | ||
scores: ["${{ test_score }}"] | ||
weights: [1.0] | ||
strategy: "mean" # mean, min, max, product, sum | ||
|
||
- name: "Report Score Manytask" | ||
run_if: ${{ !search_for_merge_request_score }} | ||
run: "report_score_manytask" | ||
args: | ||
origin: "${{ TEMP_DIR }}/${{ TASK_SUB_PATH }}" | ||
patterns: ["**/*.py"] | ||
username: ${{ USERNAME }} | ||
task_name: ${{ TASK_NAME }} | ||
score: ${{ final_score }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
version: 1 | ||
|
||
|
||
settings: | ||
timezone: Europe/Moscow | ||
|
||
deadlines: hard # hard/interpolate | ||
max_submissions: 10 # optional | ||
submission_penalty: 0.1 # optional | ||
|
||
task_url: https://example.com/$GROUP_NAME/$TASK_NAME # optional | ||
|
||
|
||
schedule: | ||
- group: 1.FirstGroup | ||
enabled: true | ||
start: 2020-01-01 18:00:00 | ||
steps: | ||
0.5: 7d | ||
end: 13d 03:00:00 | ||
tasks: | ||
- task: hello_world | ||
score: 10 | ||
bonus: 0 | ||
special: 1 | ||
- task: sum_a_b | ||
score: 5 | ||
bonus: 5 | ||
special: 0 | ||
- task: disabled_task | ||
enabled: false | ||
score: 5 | ||
|
||
- group: 2.SecondGroup | ||
start: 2020-02-01 18:00:00 | ||
steps: | ||
0.9: 2020-02-08 18:00:00 | ||
0.1: 14d | ||
tasks: | ||
- task: factorial | ||
score: 20 | ||
|
||
- group: 3.ThirdGroup | ||
start: 2020-03-01 18:00:00 | ||
tasks: | ||
- task: palindrome | ||
score: 0 | ||
special: 2 | ||
url: https://example.com | ||
|
||
- group: 4.FourthGroup | ||
enabled: false | ||
start: 2020-04-01 18:00:00 | ||
tasks: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM python:3.12.0-slim as base | ||
|
||
# set explicit timezone for time-related tasks | ||
ENV TZ Europe/Moscow | ||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | ||
|
||
# install build tools and additional tools | ||
RUN apt-get update && \ | ||
apt-get install -y build-essential curl wget git zip && \ | ||
apt-get autoremove -qyy && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
# install python dependencies | ||
COPY requirements.txt /tmp/requirements.txt | ||
RUN python3 -m pip install --upgrade -r /tmp/requirements.txt | ||
|
||
# install checker | ||
# TODO: replace with manytask-checker==1.0.0 when it's released | ||
RUN python3 -m pip install --upgrade git+https://github.com/manytask/[email protected] | ||
|
||
|
||
FROM base as testenv | ||
|
||
# copy repo for reference tests | ||
COPY . /opt/checker/private | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_extends: manytask/.github:.github/release-drafter.yml |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Release Drafter | ||
|
||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
|
||
permissions: | ||
contents: write | ||
|
||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
|
||
jobs: | ||
update_release_draft: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: release-drafter/release-drafter@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Sync PR | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- edited | ||
- synchronize | ||
- labeled | ||
- unlabeled | ||
- reopened | ||
|
||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | ||
cancel-in-progress: true | ||
|
||
|
||
jobs: | ||
autolabel_pr: | ||
permissions: | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
if: github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'edited' | ||
steps: | ||
- uses: release-drafter/release-drafter@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
validate_pr: | ||
needs: [autolabel_pr] | ||
if: ${{ always() && !failure() && !cancelled() }} # no needs jobs are failed or cancelled | ||
uses: manytask/workflows/.github/workflows/reusable-validate-pr.yml@main | ||
permissions: | ||
pull-requests: read | ||
contents: read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: 'Test private repo' | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
|
||
|
||
jobs: | ||
build-base-docker: | ||
uses: manytask/workflows/.github/workflows/reusable-docker-build-push.yml | ||
with: | ||
dockerfile: .docker | ||
target: testenv | ||
tags: testenv:${{ github.sha }} | ||
artifact: true | ||
artifact_name: testenv.tar | ||
secrets: | ||
registry_username: ${{ github.actor }} | ||
registry_password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
check-repo: | ||
needs: [build-base-docker] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download Docker Image Artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: testenv.tar | ||
path: /tmp/ | ||
|
||
- name: Load Docker Image | ||
run: | | ||
docker load --input /tmp/testenv.tar | ||
- name: Check private repo | ||
run: | | ||
# RUN: python -m /opt/checker check -- CODE_DIR" | ||
docker run \ | ||
--rm \ | ||
-v ${{ github.workspace }}:/workspace \ | ||
-w /workspace \ | ||
testenv:${{ github.sha }} \ | ||
python -m checker check /workspace /workspace |
Oops, something went wrong.