generated from UKPLab/ukp-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3b75861
Showing
31 changed files
with
1,227 additions
and
0 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,31 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: bug, help wanted | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
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,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: enhancement, question | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
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,15 @@ | ||
### Summary :memo: | ||
_Write an overview about it._ | ||
|
||
### Details | ||
_Describe more what you did on changes._ | ||
1. (...) | ||
2. (...) | ||
|
||
### Bugfixes :bug: (delete if dind't have any) | ||
- | ||
|
||
### Checks | ||
- [ ] Closed #798 | ||
- [ ] Tested Changes | ||
- [ ] Stakeholder Approval |
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,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
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,68 @@ | ||
#!/usr/bin/env bash | ||
overwrite_template_dir=0 | ||
|
||
while getopts t:o flag | ||
do | ||
case "${flag}" in | ||
t) template=${OPTARG};; | ||
o) overwrite_template_dir=1;; | ||
esac | ||
done | ||
|
||
if [ -z "${template}" ]; then | ||
echo "Available templates: flask" | ||
read -p "Enter template name: " template | ||
fi | ||
|
||
repo_urlname=$(basename -s .git `git config --get remote.origin.url`) | ||
repo_name=$(basename -s .git `git config --get remote.origin.url` | tr '-' '_' | tr '[:upper:]' '[:lower:]') | ||
repo_owner=$(git config --get remote.origin.url | awk -F ':' '{print $2}' | awk -F '/' '{print $1}') | ||
echo "Repo name: ${repo_name}" | ||
echo "Repo owner: ${repo_owner}" | ||
echo "Repo urlname: ${repo_urlname}" | ||
|
||
if [ -f ".github/workflows/rename_project.yml" ]; then | ||
.github/rename_project.sh -a "${repo_owner}" -n "${repo_name}" -u "${repo_urlname}" -d "Awesome ${repo_name} created by ${repo_owner}" | ||
fi | ||
|
||
function download_template { | ||
rm -rf "${template_dir}" | ||
mkdir -p .github/templates | ||
git clone "${template_url}" "${template_dir}" | ||
} | ||
|
||
echo "Using template:${template}" | ||
template_url="https://github.com/rochacbruno/${template}-project-template" | ||
template_dir=".github/templates/${template}" | ||
if [ -d "${template_dir}" ]; then | ||
# Template directory already exists | ||
if [ "${overwrite_template_dir}" -eq 1 ]; then | ||
# user passed -o flag, delete and re-download | ||
echo "Overwriting ${template_dir}" | ||
download_template | ||
else | ||
# Ask user if they want to overwrite | ||
echo "Directory ${template_dir} already exists." | ||
read -p "Do you want to overwrite it? [y/N] " -n 1 -r | ||
echo | ||
if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
echo "Overwriting ${template_dir}" | ||
download_template | ||
else | ||
# User decided not to overwrite | ||
echo "Using existing ${template_dir}" | ||
fi | ||
fi | ||
else | ||
# Template directory does not exist, download it | ||
echo "Downloading ${template_url}" | ||
download_template | ||
fi | ||
|
||
echo "Applying ${template} template to this project"} | ||
./.github/templates/${template}/apply.sh -a "${repo_owner}" -n "${repo_name}" -u "${repo_urlname}" -d "Awesome ${repo_name} created by ${repo_owner}" | ||
|
||
# echo "Removing temporary template files" | ||
# rm -rf .github/templates/${template} | ||
|
||
echo "Done! review, commit and push the changes" |
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,40 @@ | ||
#!/usr/bin/env bash | ||
while getopts a:n:u:d: flag | ||
do | ||
case "${flag}" in | ||
a) author=${OPTARG};; | ||
n) name=${OPTARG};; | ||
u) urlname=${OPTARG};; | ||
d) description=${OPTARG};; | ||
esac | ||
done | ||
|
||
echo "Author: $author"; | ||
echo "Project Name: $name"; | ||
echo "Project URL name: $urlname"; | ||
echo "Description: $description"; | ||
|
||
echo "Renaming project..." | ||
|
||
original_author="UKPLab" | ||
original_name="ukp_project_template" | ||
original_urlname="ukp-project-template" | ||
original_description="The official template for new Python projects at UKP Lab" | ||
# Iterate over all files in the repository | ||
git ls-files | while read -r filename; do | ||
# Exclude .github/workflows/rename_project.yml from renaming | ||
if [[ "$filename" != ".github/workflows/rename_project.yml" ]]; then | ||
sed -i "s/$original_author/$author/g" "$filename" | ||
sed -i "s/$original_name/$name/g" "$filename" | ||
sed -i "s/$original_urlname/$urlname/g" "$filename" | ||
sed -i "s/$original_description/$description/g" "$filename" | ||
echo "Renamed $filename" | ||
else | ||
echo "Skipping $filename" | ||
fi | ||
done | ||
|
||
mv "$original_name" "$name" | ||
|
||
# This command runs only once on GHA! | ||
rm -rf .github/template.yml |
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 @@ | ||
author: UKPLab |
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,31 @@ | ||
name: Build Docs | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Change this to your main branch name | ||
pull_request: | ||
branches: | ||
- main # Change this to your main branch name | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 # Change this to your Python version | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements-dev.txt | ||
- name: Build Docs | ||
run: | | ||
python -m mkdocs build --verbose |
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,70 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
name: CI | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the main branch | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
check-files: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check files | ||
run: | | ||
# Define the list of filenames you want to check | ||
FILES_TO_CHECK=("LICENSE" "README.md" "requirements.txt" "requirements-dev.txt" "NOTICE.txt" "setup.py") | ||
# Initialize a variable to track missing files | ||
MISSING_FILES=() | ||
# Check if each file exists in the root directory | ||
for FILE in "${FILES_TO_CHECK[@]}"; do | ||
if [ ! -f "$FILE" ]; then | ||
MISSING_FILES+=("$FILE") | ||
fi | ||
done | ||
# Output the missing files | ||
if [ ${#MISSING_FILES[@]} -eq 0 ]; then | ||
echo "All files exist." | ||
else | ||
echo "The following files are missing:" | ||
for MISSING_FILE in "${MISSING_FILES[@]}"; do | ||
echo "- $MISSING_FILE" | ||
done | ||
echo "::error::One or more files are missing." | ||
exit 1 | ||
fi | ||
linter: | ||
runs-on: ubuntu-latest | ||
needs: check-files | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install -r requirements-dev.txt | ||
- name: Analysing the code with pylint | ||
run: | | ||
pylint --disable=trailing-whitespace,missing-class-docstring,missing-final-newline,trailing-newlines \ | ||
--fail-under=9.0 \ | ||
$(git ls-files '*.py') || echo "::warning::Pylint check failed, but the workflow will continue." |
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,42 @@ | ||
name: Rename the project from template | ||
|
||
on: [push] | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
rename-project: | ||
if: ${{ !contains (github.repository, '/ukp-project-template') }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
# by default, it uses a depth of 1 | ||
# this fetches all history so that we can read each commit | ||
fetch-depth: 0 | ||
ref: ${{ github.head_ref }} | ||
|
||
- run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- run: echo "REPOSITORY_URLNAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- run: echo "REPOSITORY_OWNER=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- name: Is this still a template | ||
id: is_template | ||
run: echo "::set-output name=is_template::$(ls .github/template.yml &> /dev/null && echo true || echo false)" | ||
|
||
- name: Rename the project | ||
if: steps.is_template.outputs.is_template == 'true' | ||
run: | | ||
echo "Renaming the project with -a(author) ${{ env.REPOSITORY_OWNER }} -n(name) ${{ env.REPOSITORY_NAME }} -u(urlname) ${{ env.REPOSITORY_URLNAME }}" | ||
.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 }}" | ||
- uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: "✅ Ready to clone and code." | ||
# commit_options: '--amend --no-edit' | ||
push_options: --force |
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,49 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
name: Run tests | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the main branch | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
tests: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install . | ||
pip install -r requirements-dev.txt | ||
# Hacky way to get package name from setup.py | ||
- name: Get package name | ||
id: get_package_name | ||
run: | | ||
setup_file="setup.py" | ||
pattern="name=" | ||
project_name=$(grep -oP "(?<=${pattern}\")[^\"]+" $setup_file) | ||
echo "::set-output name=package_name::$project_name" | ||
- name: Run tests | ||
run: | | ||
pytest -v --cov-fail-under=60 --cov=${{ steps.get_package_name.outputs.package_name }} -l --tb=short --maxfail=1 tests/ | ||
coverage xml | ||
coverage html |
Oops, something went wrong.