Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update template #10

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "LaTeX4Ei Devcontainer",
"image": "makeappdev/uselatex:latest",
"extensions": [
"eamodio.gitlens",
"James-Yu.latex-workshop",
"ms-azuretools.vscode-docker",
"ms-vscode-remote.vscode-remote-extensionpack",
"ms-vscode.cmake-tools",
"twxs.cmake"
],
}
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: 🔍 Search for existing issues first.
url: https://github.com/latex4ei/Allgemein/issues
about: Please search to see if an issue already exists, either in this repo or our common issue in https://github.com/latex4ei/Allgemein/issues
45 changes: 45 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Feature request
description: Suggest an idea for this project
labels: [enhancement]
assignees: []

body:
- type: markdown
attributes:
value: |
**Is your feature request related to a problem? Please describe.**
- type: textarea
id: problem-description
attributes:
label: Problem Description
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

- type: markdown
attributes:
value: |
**Describe the solution you'd like**
- type: textarea
id: solution-description
attributes:
label: Solution Description
description: A clear and concise description of what you want to happen.

- type: markdown
attributes:
value: |
**Describe alternatives you've considered**
- type: textarea
id: alternatives-description
attributes:
label: Alternatives Description
description: A clear and concise description of any alternative solutions or features you've considered.

- type: markdown
attributes:
value: |
**Additional context**
- type: textarea
id: additional-context
attributes:
label: Additional Context
description: Add any other context or screenshots about the feature request here.
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/inhaltlicher_fehler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Inhaltlicher Fehler
description: Hilf uns Fehler zu Verbessern
labels: [bug]
assignees: []

body:
- type: markdown
attributes:
value: |
**Fehlerbeschreibung**
- type: textarea
id: error-description
attributes:
label: Fehlerbeschreibung
description: Beschreibe hier den Fehler

- type: markdown
attributes:
value: |
**Referenz**
- type: textarea
id: reference
attributes:
label: Referenz
description: Wenn möglich immer eine Referenz zum Skript o.ä. angeben oder als Screenshot mit einfügen.
56 changes: 51 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,60 @@
name: CI

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12.2'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r scripts/requirements.txt
- name: Run pytest
run: pytest

build:
runs-on: ubuntu-latest
container: makeappdev/uselatex:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run a trivial command
run: echo "This is a placeholder workflow"
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git safe directory with GITHUB_WORKSPACE
run: git config --global --add safe.directory $GITHUB_WORKSPACE

- name: Build
run: |
cmake --version; pdflatex --version
mkdir -p build && cd build
cmake ..
make

- name: Prepare Deployment
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
run: |
mkdir -p export
echo "# This branch is for deployment only" >> export/README.md
cp build/*.pdf export
cp build/git.id export

- name: Deploy
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: export
single-commit: true
silent: true
38 changes: 38 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Update README and LaTeX Build File

on:
workflow_dispatch:

jobs:
update-and-create-pr:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12.2'

- name: Run update script
run: python scripts/update_files.py

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Commit changes to a new branch
run: |
git checkout -b changes/${{ github.run_id }}
git add .
git commit -m "Apply automated updates"
git push -u origin changes/${{ github.run_id }}

- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create --base main --head changes/${{ github.run_id }} --title "Specify project URLs and CMake project" --body "Please review the changes applied by the automated script."
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build/

Systemtheorie.pdf
/*.pdf
dariusptrs marked this conversation as resolved.
Show resolved Hide resolved

## Core latex/pdflatex auxiliary files:
*.aux
Expand Down Expand Up @@ -111,4 +111,6 @@ sympy-plots-for-*.tex/

# xindy
*.xdy
StochastischeSignale.pdf
git.id
*.DS_Store
*.pyc
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

68 changes: 68 additions & 0 deletions Systemtheorie.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,74 @@
\usepackage{latexnew}


%UPDATE WITHOUT CLASS CHANGE
% ----------------------------------------------------------------------

% LastPage
\usepackage{lastpage}

% Allow hyperlinks
\RequirePackage[pagebackref=true,pdfpagelabels]{hyperref}

% Colors
\RequirePackage{latex4ei/latex4ei_colors}
\colorlet{col_link}{tum_blue_dark}
\hypersetup{
colorlinks=true,
linkcolor=col_link,
urlcolor=col_link,
citecolor=col_link,
}

% set pdfoptions
\AtBeginDocument{
\hypersetup{
pdftitle={Analysis 1},
pdfauthor={Lukas Kompatscher},
pdfcreator={LaTeX4EI template (www.latex4ei.de)},
pdfkeywords={latex4ei}
}
}

% Date with git commit number
\newcommand{\themydate}{\today} % Default URL placeholder
\newcommand{\mydate}[1]{\renewcommand{\themydate}{#1}}

% Header and Footer
\RequirePackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}

\AtBeginDocument{
\IfFileExists{git.id}{\input{git.id}}{}
\ifdefined\GitNiceDate\mydate{\GitNiceDate\ (git \GitRevision)}\fi
\ifdefined\GitIssuesURL
\ifdefined\setissueslinkurl
\setissueslinkurl{\GitIssuesURL} % Set the actual URL
\fi
\fi
}

% Define Email
\providecommand{\email}[1]{\href{mailto:#1}{\nolinkurl{#1}}}

%
\fancyfoot[C]{von Lukas Kompatscher\ -- Mail: \email{[email protected]}}
\fancyfoot[R]{Stand: \themydate \qquad \thepage/\pageref{LastPage}}
\fancyfoot[L]{Homepage: \url{www.latex4ei.de} -- Fehler bitte \emph{sofort} \href{\issueslinkurl}{melden}.}

\renewcommand{\headrulewidth}{0.0pt} %obere Linie ausblenden
\renewcommand{\footrulewidth}{0.1pt} %obere Linie ausblenden

\newcommand{\issueslinkurl}{https://github.com/latex4ei/Allgemein/issues} % Default URL placeholder
\newcommand{\setissueslinkurl}[1]{\renewcommand{\issueslinkurl}{#1}}

\titleformat{\subsubsection}
{\normalfont\normalsize\bfseries}{\thesubsubsection}{1em}{}

% ----------------------------------------------------------------------

% Dokumentbeginn
% =======================================================================
\begin{document}
Expand Down
Empty file added scripts/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pyfakefs==5.3.5
pytest==8.1.1
Empty file added scripts/tests/__init__.py
Empty file.
75 changes: 75 additions & 0 deletions scripts/tests/test_update_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import pytest
from scripts.update_files import check_tex_file_exists, update_readme_content, update_cmake_content
from pathlib import Path
import os

@pytest.fixture
def fake_base_path(fs):
"""Fixture to create a base path and mock environment variable."""
base_path = Path("/test/project")
fs.create_dir(base_path)
os.environ['GITHUB_REPOSITORY'] = 'user/correct_title'
return base_path

def test_check_tex_file_exists__file_does_not_exist__should_raise(fake_base_path, fs):
repo_name = "correct_title"
fs.create_file(fake_base_path / f"{repo_name}.tex")
check_tex_file_exists(repo_name, fake_base_path)

with pytest.raises(FileNotFoundError):
check_tex_file_exists("nonexistent_repo", Path(fake_base_path))

def test_update_readme_content(fake_base_path, fs):
initial_readme_content = """
# WrongTitle
Some content in the README file.
[![Actions Status](https://github.com/latex4ei/WrongCheatsheetTemplate/workflows/CI/badge.svg)](https://github.com/latex4ei/WrongCheatsheetTemplate)
## Section
More details here.
""".strip()
fs.create_file(fake_base_path / "README.md", contents=initial_readme_content)
repo_name = "correct_title"
github_repository = 'user/correct_title'

updated_content = update_readme_content(initial_readme_content, repo_name, github_repository)

expected_content = """
# correct_title
Some content in the README file.
[![Actions Status](https://github.com/user/correct_title/workflows/CI/badge.svg)](https://github.com/user/correct_title)
## Section
More details here.
""".strip()
assert updated_content == expected_content, "README.md content was not updated correctly."

def test_update_cmake_content(fake_base_path, fs):
initial_cmake_content = """
cmake_minimum_required(VERSION 3.12)
project(WrongProjectName NONE)
# Add the main LaTeX document
add_latex_document(
CheatsheetTemplate.tex
AnotherDoc.tex
FORCE_PDF
IMAGE_DIRS img
DEPENDS writegitid
)
""".strip()
fs.create_file(fake_base_path / "CMakeLists.txt", contents=initial_cmake_content)
repo_name = "correct_title"

updated_content = update_cmake_content(initial_cmake_content, repo_name)

expected_content = """
cmake_minimum_required(VERSION 3.12)
project(correct_title NONE)
# Add the main LaTeX document
add_latex_document(
correct_title.tex
AnotherDoc.tex
FORCE_PDF
IMAGE_DIRS img
DEPENDS writegitid
)
""".strip()
assert updated_content == expected_content, "CMakeLists.txt content was not updated correctly."
Loading
Loading