From e349c07d0b116ebf0e4ccdf890ef4b901ed47063 Mon Sep 17 00:00:00 2001 From: Pedro T <122754753+ptonso@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:38:46 -0300 Subject: [PATCH] Initial commit --- .github/PULL_REQUEST_TEMPLATE.md | 17 +++++++ .github/workflows/new-activity-validation.yml | 40 +++++++++++++++++ .github/workflows/structure-validation.yml | 44 +++++++++++++++++++ README.md | 8 ++++ pre-commit-config.yaml | 16 +++++++ task1/README.md | 5 +++ task1/example_author.py | 0 task2/README.md | 0 task2/example_author.py | 0 9 files changed, 130 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/new-activity-validation.yml create mode 100644 .github/workflows/structure-validation.yml create mode 100644 README.md create mode 100644 pre-commit-config.yaml create mode 100644 task1/README.md create mode 100644 task1/example_author.py create mode 100644 task2/README.md create mode 100644 task2/example_author.py diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..e895bb2 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ +## Descrição + +Descreva sua alteração no repositório (opcional) + +## Tipo de Mudança + +Selecione as opções aplicáveis + +- [ ] Novo Diretório (Adicionando nova atividade) +- [ ] Minha atividade (Compartilhando meu código) +- [ ] Alterações no Repositório + +## Checklist: + +- [ ] Meu código está funcional +- [ ] Aceito que outras pessoas consumam meu código +- [ ] Não é plágio e, caso aplicável, citei as referências diff --git a/.github/workflows/new-activity-validation.yml b/.github/workflows/new-activity-validation.yml new file mode 100644 index 0000000..7d2b60a --- /dev/null +++ b/.github/workflows/new-activity-validation.yml @@ -0,0 +1,40 @@ +# Ensuring that every time a new directory is added to the repository, +# the README.md file in the root is updated with a reference to its content. + +name: Validate README.md Update + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + check-readme: + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v3 + + - name: Set up Git + run: git fetch --all + + - name: Identify new directories + id: new_dirs + run: | + new_dirs=$(git diff --name-status origin/main | awk '$1 == "A" && $2 ~ /\/$/ {print $2}') + echo "New directories added: $new_dirs" + echo "::set-output name=new_dirs::$new_dirs" + + - name: Check if README.md was modified + if: steps.new_dirs.outputs.new_dirs != '' + run: | + readme_changed=$(git diff --name-only origin/main | grep -c "README.md" || true) + if [ $readme_changed -eq 0 ]; then + echo "README.md was not updated. Please update it to reflect new directories." + exit 1 + else + echo "README.md was updated." + fi diff --git a/.github/workflows/structure-validation.yml b/.github/workflows/structure-validation.yml new file mode 100644 index 0000000..f9141f0 --- /dev/null +++ b/.github/workflows/structure-validation.yml @@ -0,0 +1,44 @@ +name: Validate Repository Structure + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + validate-structure: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Validate Repository Structure + run: | + # Ensure the main README.md exists + if [ ! -f "README.md" ]; then + echo "Root README.md is missing. Please add a README.md with discipline name and code." + exit 1 + fi + + # Ensure each task folder has a README.md and no unauthorized files + for dir in */ ; do + if [ ! -f "${dir}/README.md" ]; then + echo "Task ${dir} is missing a README.md. Each task folder must have a README.md file with the task description." + exit 1 + fi + + # Check that every file in the task folder follows the author naming convention + for file in "${dir}"*; do + filename=$(basename "$file") + if [[ "$filename" != *"."* ]]; then + echo "File ${filename} in ${dir} does not follow the naming convention. It should be named as 'author.extension'." + exit 1 + fi + done + done + + echo "Repository structure is valid." diff --git a/README.md b/README.md new file mode 100644 index 0000000..96cd04a --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# [Discipline Code] +[Discipline name] + +# Pastas por tópicos: + +## Tópico 1 +- [Task 1](./task1) +- [Task 2](./task2) \ No newline at end of file diff --git a/pre-commit-config.yaml b/pre-commit-config.yaml new file mode 100644 index 0000000..719f18a --- /dev/null +++ b/pre-commit-config.yaml @@ -0,0 +1,16 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.2.1 + hooks: + - id: no-commit-to-branch + args: ['--pattern', '^(?!((new_dir|new_ex|bugfix)\/[a-zA-Z0-9\-]+)$).*'] + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-yaml + - id: check-json + - id: check-merge-conflict + - id: check-toml diff --git a/task1/README.md b/task1/README.md new file mode 100644 index 0000000..49f5004 --- /dev/null +++ b/task1/README.md @@ -0,0 +1,5 @@ +# Descrição da tarefa + +Adicione o enunciado ou descrição desta tarefa + +Sua solução deve respeitar o formato `seu_nome.extensao`. diff --git a/task1/example_author.py b/task1/example_author.py new file mode 100644 index 0000000..e69de29 diff --git a/task2/README.md b/task2/README.md new file mode 100644 index 0000000..e69de29 diff --git a/task2/example_author.py b/task2/example_author.py new file mode 100644 index 0000000..e69de29