Skip to content

Commit 2eeee95

Browse files
Initial commit
0 parents  commit 2eeee95

31 files changed

+1227
-0
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug, help wanted
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Version [e.g. 22]
29+
30+
**Additional context**
31+
Add any other context about the problem here.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: enhancement, question
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### Summary :memo:
2+
_Write an overview about it._
3+
4+
### Details
5+
_Describe more what you did on changes._
6+
1. (...)
7+
2. (...)
8+
9+
### Bugfixes :bug: (delete if dind't have any)
10+
-
11+
12+
### Checks
13+
- [ ] Closed #798
14+
- [ ] Tested Changes
15+
- [ ] Stakeholder Approval

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/init.sh

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
overwrite_template_dir=0
3+
4+
while getopts t:o flag
5+
do
6+
case "${flag}" in
7+
t) template=${OPTARG};;
8+
o) overwrite_template_dir=1;;
9+
esac
10+
done
11+
12+
if [ -z "${template}" ]; then
13+
echo "Available templates: flask"
14+
read -p "Enter template name: " template
15+
fi
16+
17+
repo_urlname=$(basename -s .git `git config --get remote.origin.url`)
18+
repo_name=$(basename -s .git `git config --get remote.origin.url` | tr '-' '_' | tr '[:upper:]' '[:lower:]')
19+
repo_owner=$(git config --get remote.origin.url | awk -F ':' '{print $2}' | awk -F '/' '{print $1}')
20+
echo "Repo name: ${repo_name}"
21+
echo "Repo owner: ${repo_owner}"
22+
echo "Repo urlname: ${repo_urlname}"
23+
24+
if [ -f ".github/workflows/rename_project.yml" ]; then
25+
.github/rename_project.sh -a "${repo_owner}" -n "${repo_name}" -u "${repo_urlname}" -d "Awesome ${repo_name} created by ${repo_owner}"
26+
fi
27+
28+
function download_template {
29+
rm -rf "${template_dir}"
30+
mkdir -p .github/templates
31+
git clone "${template_url}" "${template_dir}"
32+
}
33+
34+
echo "Using template:${template}"
35+
template_url="https://github.com/rochacbruno/${template}-project-template"
36+
template_dir=".github/templates/${template}"
37+
if [ -d "${template_dir}" ]; then
38+
# Template directory already exists
39+
if [ "${overwrite_template_dir}" -eq 1 ]; then
40+
# user passed -o flag, delete and re-download
41+
echo "Overwriting ${template_dir}"
42+
download_template
43+
else
44+
# Ask user if they want to overwrite
45+
echo "Directory ${template_dir} already exists."
46+
read -p "Do you want to overwrite it? [y/N] " -n 1 -r
47+
echo
48+
if [[ $REPLY =~ ^[Yy]$ ]]; then
49+
echo "Overwriting ${template_dir}"
50+
download_template
51+
else
52+
# User decided not to overwrite
53+
echo "Using existing ${template_dir}"
54+
fi
55+
fi
56+
else
57+
# Template directory does not exist, download it
58+
echo "Downloading ${template_url}"
59+
download_template
60+
fi
61+
62+
echo "Applying ${template} template to this project"}
63+
./.github/templates/${template}/apply.sh -a "${repo_owner}" -n "${repo_name}" -u "${repo_urlname}" -d "Awesome ${repo_name} created by ${repo_owner}"
64+
65+
# echo "Removing temporary template files"
66+
# rm -rf .github/templates/${template}
67+
68+
echo "Done! review, commit and push the changes"

.github/rename_project.sh

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
while getopts a:n:u:d: flag
3+
do
4+
case "${flag}" in
5+
a) author=${OPTARG};;
6+
n) name=${OPTARG};;
7+
u) urlname=${OPTARG};;
8+
d) description=${OPTARG};;
9+
esac
10+
done
11+
12+
echo "Author: $author";
13+
echo "Project Name: $name";
14+
echo "Project URL name: $urlname";
15+
echo "Description: $description";
16+
17+
echo "Renaming project..."
18+
19+
original_author="UKPLab"
20+
original_name="ukp_project_template"
21+
original_urlname="ukp-project-template"
22+
original_description="The official template for new Python projects at UKP Lab"
23+
# Iterate over all files in the repository
24+
git ls-files | while read -r filename; do
25+
# Exclude .github/workflows/rename_project.yml from renaming
26+
if [[ "$filename" != ".github/workflows/rename_project.yml" ]]; then
27+
sed -i "s/$original_author/$author/g" "$filename"
28+
sed -i "s/$original_name/$name/g" "$filename"
29+
sed -i "s/$original_urlname/$urlname/g" "$filename"
30+
sed -i "s/$original_description/$description/g" "$filename"
31+
echo "Renamed $filename"
32+
else
33+
echo "Skipping $filename"
34+
fi
35+
done
36+
37+
mv "$original_name" "$name"
38+
39+
# This command runs only once on GHA!
40+
rm -rf .github/template.yml

.github/template.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
author: UKPLab

.github/workflows/docs.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Change this to your main branch name
7+
pull_request:
8+
branches:
9+
- main # Change this to your main branch name
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v2
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.9 # Change this to your Python version
23+
24+
- name: Install Dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -r requirements-dev.txt
28+
29+
- name: Build Docs
30+
run: |
31+
python -m mkdocs build --verbose

.github/workflows/main.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# This is a basic workflow to help you get started with Actions
2+
name: CI
3+
4+
# Controls when the workflow will run
5+
on:
6+
# Triggers the workflow on push or pull request events but only for the main branch
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
15+
jobs:
16+
17+
check-files:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Check files
24+
run: |
25+
# Define the list of filenames you want to check
26+
FILES_TO_CHECK=("LICENSE" "README.md" "requirements.txt" "requirements-dev.txt" "NOTICE.txt" "setup.py")
27+
28+
# Initialize a variable to track missing files
29+
MISSING_FILES=()
30+
31+
# Check if each file exists in the root directory
32+
for FILE in "${FILES_TO_CHECK[@]}"; do
33+
if [ ! -f "$FILE" ]; then
34+
MISSING_FILES+=("$FILE")
35+
fi
36+
done
37+
38+
# Output the missing files
39+
if [ ${#MISSING_FILES[@]} -eq 0 ]; then
40+
echo "All files exist."
41+
else
42+
echo "The following files are missing:"
43+
for MISSING_FILE in "${MISSING_FILES[@]}"; do
44+
echo "- $MISSING_FILE"
45+
done
46+
echo "::error::One or more files are missing."
47+
exit 1
48+
fi
49+
50+
linter:
51+
runs-on: ubuntu-latest
52+
needs: check-files
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v4
56+
57+
- name: Set up Python
58+
uses: actions/setup-python@v4
59+
with:
60+
python-version: 3.9
61+
62+
- name: Install dependencies
63+
run: |
64+
pip install -r requirements-dev.txt
65+
66+
- name: Analysing the code with pylint
67+
run: |
68+
pylint --disable=trailing-whitespace,missing-class-docstring,missing-final-newline,trailing-newlines \
69+
--fail-under=9.0 \
70+
$(git ls-files '*.py') || echo "::warning::Pylint check failed, but the workflow will continue."

.github/workflows/rename_project.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Rename the project from template
2+
3+
on: [push]
4+
5+
permissions: write-all
6+
7+
jobs:
8+
rename-project:
9+
if: ${{ !contains (github.repository, '/ukp-project-template') }}
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
# by default, it uses a depth of 1
15+
# this fetches all history so that we can read each commit
16+
fetch-depth: 0
17+
ref: ${{ github.head_ref }}
18+
19+
- run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
20+
shell: bash
21+
22+
- run: echo "REPOSITORY_URLNAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
23+
shell: bash
24+
25+
- run: echo "REPOSITORY_OWNER=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV
26+
shell: bash
27+
28+
- name: Is this still a template
29+
id: is_template
30+
run: echo "::set-output name=is_template::$(ls .github/template.yml &> /dev/null && echo true || echo false)"
31+
32+
- name: Rename the project
33+
if: steps.is_template.outputs.is_template == 'true'
34+
run: |
35+
echo "Renaming the project with -a(author) ${{ env.REPOSITORY_OWNER }} -n(name) ${{ env.REPOSITORY_NAME }} -u(urlname) ${{ env.REPOSITORY_URLNAME }}"
36+
.github/rename_project.sh -a ${{ env.REPOSITORY_OWNER }} -n ${{ env.REPOSITORY_NAME }} -u ${{ env.REPOSITORY_URLNAME }} -d "Awesome ${{ env.REPOSITORY_NAME }} created by ${{ env.REPOSITORY_OWNER }}"
37+
38+
- uses: stefanzweifel/git-auto-commit-action@v5
39+
with:
40+
commit_message: "✅ Ready to clone and code."
41+
# commit_options: '--amend --no-edit'
42+
push_options: --force

.github/workflows/tests.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This is a basic workflow to help you get started with Actions
2+
name: Run tests
3+
4+
# Controls when the workflow will run
5+
on:
6+
# Triggers the workflow on push or pull request events but only for the main branch
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
15+
jobs:
16+
tests:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest]
21+
runs-on: ${{ matrix.os }}
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: 3.9
30+
31+
- name: Install dependencies
32+
run: |
33+
pip install .
34+
pip install -r requirements-dev.txt
35+
36+
# Hacky way to get package name from setup.py
37+
- name: Get package name
38+
id: get_package_name
39+
run: |
40+
setup_file="setup.py"
41+
pattern="name="
42+
project_name=$(grep -oP "(?<=${pattern}\")[^\"]+" $setup_file)
43+
echo "::set-output name=package_name::$project_name"
44+
45+
- name: Run tests
46+
run: |
47+
pytest -v --cov-fail-under=60 --cov=${{ steps.get_package_name.outputs.package_name }} -l --tb=short --maxfail=1 tests/
48+
coverage xml
49+
coverage html

0 commit comments

Comments
 (0)