Skip to content

Commit 766642f

Browse files
authored
Initial commit
0 parents  commit 766642f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+4832
-0
lines changed

.codacy.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
exclude_paths:
3+
- "**/test/**"
4+
- "README.md"
5+
- "**/README.md"

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "maven"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"
12+
- package-ecosystem: "github-actions"
13+
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
14+
directory: "/"
15+
schedule:
16+
interval: "daily"

.github/workflows/build-report.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Build & Report
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- '**'
11+
tags-ignore:
12+
- '**'
13+
paths-ignore:
14+
- '.github/**'
15+
pull_request:
16+
branches:
17+
- '**'
18+
tags-ignore:
19+
- '**'
20+
paths-ignore:
21+
- '.github/**'
22+
23+
jobs:
24+
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
submodules: recursive
31+
token: ${{ secrets.PAT_TOKEN }}
32+
- uses: actions/cache@v4
33+
with:
34+
path: ~/.m2/repository
35+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
36+
restore-keys: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
37+
- name: Set up JDK 17
38+
uses: actions/setup-java@v4
39+
with:
40+
distribution: temurin
41+
java-version: 17
42+
- name: Build with Maven
43+
run: mvn -B package --file pom.xml
44+
- name: Upload Jacoco report artifact
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: jacoco-report
48+
path: target/site/jacoco/jacoco.xml
49+
50+
report:
51+
runs-on: ubuntu-latest
52+
needs: build
53+
steps:
54+
- uses: actions/checkout@v4
55+
- name: Download Jacoco report artifact
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: jacoco-report
59+
path: target/site/jacoco
60+
- uses: codecov/codecov-action@v4
61+
name: Send coverage to Codecov
62+
with:
63+
file: ./**/target/site/jacoco/jacoco.xml
64+
name: codecov
65+
- name: Send coverage to Codacy
66+
uses: codacy/codacy-coverage-reporter-action@master
67+
with:
68+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}

.github/workflows/update-year.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Update year
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
aoc_year:
6+
description: 'Advent of Code year'
7+
required: true
8+
default: 'yyyy'
9+
jobs:
10+
verify:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check Repository
14+
run: |
15+
if [ "${{ github.repository }}" == "Flashky/advent-of-code-yyyy" ]; then
16+
echo -e "\e[91mError: This workflow cannot be run from the template repository.\e[0m"
17+
exit 1
18+
fi
19+
- name: Check for Token Secret
20+
run: |
21+
if [ -z "${{ secrets.PAT_TOKEN }}" ]; then
22+
echo -e "\e[91mError: PAT_TOKEN secret is not set.\e[0m"
23+
echo -e "\e[93mTo generate a personal access token (PAT) for GitHub Actions:\e[0m"
24+
echo -e "\e[93m1. Go to \e[94mhttps://github.com/settings/tokens\e[0m"
25+
echo -e "\e[93m2. Click on \e[92mGenerate new token\e[0m\e[93m and then on \e[92mGenerate new token (classic) \e[0m\e[93m\e[0m"
26+
echo -e "\e[93m3. Give your token a name, select the required scopes (e.g., repo), and click on \e[92mGenerate token\e[93m\e[0m"
27+
echo -e "\e[93m4. Copy the generated token"
28+
echo -e "\e[93m5. Go to your repository on GitHub -> Settings -> Secrets -> New repository secret"
29+
echo -e "\e[93m6. Name the secret \e[94mPAT_TOKEN\e[93m and paste the copied token as the value"
30+
exit 1
31+
fi
32+
- name: Check Year Format
33+
run: |
34+
if echo "${{ github.event.inputs.aoc_year }}" | grep -E -q '^[0-9]{4}$'; then
35+
echo "Year '${{ github.event.inputs.aoc_year }}' format is valid."
36+
else
37+
echo -e "\e[91mError: Invalid year format ('${{ github.event.inputs.aoc_year }}'). Please provide a valid 4-digit year.\e[0m"
38+
exit 1
39+
fi
40+
update:
41+
needs: verify
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: Update Repository Description
46+
run: |
47+
token="${{ secrets.PAT_TOKEN }}"
48+
url=https://api.github.com/repos/${{ github.repository }}
49+
description='{"description": "Advent of Code ${{ github.event.inputs.aoc_year }}"}'
50+
curl -X PATCH -H "Authorization: Bearer $token" -H "Accept: application/vnd.github.v3+json" -d "$description" $url
51+
- name: Update Repository Topics
52+
run: |
53+
token="${{ secrets.PAT_TOKEN }}"
54+
url="https://api.github.com/repos/${{ github.repository }}/topics"
55+
topics='{"names": ["java", "advent-of-code", "advent-of-code-${{ github.event.inputs.aoc_year }}", "advent-of-code-${{ github.event.inputs.aoc_year }}-java"]}'
56+
curl -X PUT -H "Authorization: Bearer $token" -H "Accept: application/vnd.github.mercy-preview+json" -d "$topics" $url
57+
- name: Update README.md
58+
run: |
59+
find . -name 'README.md' | xargs sed -i 's/{year}/'${{ github.event.inputs.aoc_year }}'/g'
60+
- name: Update pom.xml
61+
run: |
62+
find . -name 'pom.xml' | xargs sed -i 's/yyyy/'${{ github.event.inputs.aoc_year }}'/g'
63+
- name: Open Pull Request
64+
uses: peter-evans/create-pull-request@v7
65+
id: pull-request
66+
with:
67+
token: ${{ secrets.GITHUB_TOKEN }}
68+
commit-message: "Update year to ${{ github.event.inputs.aoc_year }}"
69+
title: "Update year to ${{ github.event.inputs.aoc_year }}"
70+
body: |
71+
This PR is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request).
72+
- name: Check PR information
73+
if: ${{ steps.pull-request.outputs.pull-request-number }}
74+
run: |
75+
echo "Pull Request Number - ${{ steps.pull-request.outputs.pull-request-number }}"
76+
echo "Pull Request URL - ${{ steps.pull-request.outputs.pull-request-url }}"
77+
78+

.gitignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Standard .gitignore file to use on any project
2+
# Add to root project folder.
3+
4+
# Compiled class file
5+
*.class
6+
7+
# Log file
8+
*.log
9+
10+
# BlueJ files
11+
*.ctxt
12+
13+
# Mobile Tools for Java (J2ME)
14+
.mtj.tmp/
15+
16+
# Package Files #
17+
*.jar
18+
*.war
19+
*.nar
20+
*.ear
21+
*.zip
22+
*.tar.gz
23+
*.rar
24+
25+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
26+
hs_err_pid*
27+
28+
# Eclipse folders
29+
.classpath
30+
.project
31+
.settings
32+
.mvn
33+
.factorypath
34+
35+
# Intellij folders
36+
.idea/
37+
*.iml
38+
*.iws
39+
40+
# VSCode folders
41+
.vscode
42+
43+
# Maven
44+
log/
45+
target/
46+
47+
# Input files
48+
*.input

README.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Advent of Code {year}
2+
3+
## Housekeeping
4+
5+
Before creating a new repository from this template, perform the following steps.
6+
7+
### Personal Access Token Setup
8+
9+
Open **[Personal access tokens (classic)](https://github.com/settings/tokens)** settings and verify if there is any
10+
``PAT_TOKEN`` or if it is nearly to expire.
11+
12+
#### Creation of a new token
13+
14+
If there is no ``PAT_TOKEN`` created:
15+
16+
1. Click on **Generate New Token**.
17+
2. Select ``repo`` checkbox.
18+
3. Copy the token.
19+
20+
#### Refresh of an existing token
21+
22+
If there is an existing ``PAT_TOKEN``:
23+
24+
1. Click on it.
25+
2. If the expiration date is due soon, click on **regenerate the token**.
26+
3. Update the ``PAT_TOKEN`` at this template repository.
27+
28+
### Update dependencies
29+
30+
Open [dependency graph](https://github.com/Flashky/advent-of-code-yyyy/network/updates) settings
31+
and manually run the following jobs:
32+
33+
- ``pom.xml``
34+
- ``.github/workflows/build-report.yml``
35+
36+
Review and merge any pending pull requests.
37+
38+
## New repository creation
39+
40+
Follow this steps after housekeeping is finished.
41+
42+
### Creation
43+
44+
1. Open the main page of the [template repository](https://github.com/Flashky/advent-of-code-yyyy).
45+
2. Click on **Use this template**.
46+
3. Select **Create a new repository**:
47+
1. Give a name to the new repository. Example: ``advent-of-code-2022``.
48+
49+
### Personal Access Token Setup
50+
51+
Add the previously mentioned ``PAT_TOKEN`` to this new repository.
52+
53+
### Codacy Project Token Setup
54+
55+
1. Go to [Codacy](https://app.codacy.com) and add the repository.
56+
2. Open **Settings / Coverage** and copy the ``CODACY_PROJECT_TOKEN`` value.
57+
3. Open the created repository.
58+
4. Open **Settings / Secrets and variables / Actions** and click on **New repository secret**:
59+
1. **Name:** ``CODACY_PROJECT_TOKEN``
60+
2. **Secret:** The previously copied token.
61+
62+
### Update repository information
63+
64+
1. Go to **Settings / Actions / General**.
65+
2. Under **Workflow permissions**:
66+
1. Enable **Read and write permissions**.
67+
2. Enable **Allow GitHub Actions to create and approve pull requests**.
68+
4. Go to **Actions** and open the **Update year** workflow:
69+
1. Click on **Run workflow**.
70+
2. Type the year in ``yyyy`` format and click on **Run workflow**.
71+
72+
After the workflow has ended a Pull Request will be created:
73+
1. Open the [pull request](https://github.com/Flashky/advent-of-code-{year}/pull/1).
74+
2. Verify everything is right and then **merge** it.
75+
76+
After the PR is merged the repository will have its description and topics updated. Also, all ``README.md`` and ``pom.xml`` will be updated with current year value. The PR can be declined and workflow can be executed again if there was any problem that needed a fix.
77+
78+
### Data Repository Setup
79+
80+
1. Create a private data repository using [advent-of-code-yyyy-data](https://github.com/Flashky/advent-of-code-yyyy-data) template repository and set it up.
81+
2. Add the data repository as a [submodule](https://github.blog/2016-02-01-working-with-submodules/) using the command:
82+
83+
```bash
84+
git clone https://github.com/Flashky/advent-of-code-{year}.git &&
85+
git submodule add -b master https://github.com/Flashky/advent-of-code-{year}-data.git advent-of-code-{year}/src/test/resources/inputs &&
86+
git push
87+
```
88+
89+
### Codacy Badges Setup
90+
91+
1. Go to [Codacy](https://app.codacy.com) and open the repository.
92+
2. Open **Settings / General** and copy both the ``code quality`` and ``coverage`` badges.
93+
3. Add them to this ``README.md``.
94+
95+
### Almost done...
96+
97+
1. Remove these instructions from ``README.md``.
98+
2. Push the changes and...
99+
100+
**Enjoy your new Advent of Code edition!**
101+
102+
---
103+
104+
- [Day 1](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day01)
105+
- [Day 2](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day02)
106+
- [Day 3](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day03)
107+
- [Day 4](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day04)
108+
- [Day 5](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day05)
109+
- [Day 6](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day06)
110+
- [Day 7](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day07)
111+
- [Day 8](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day08)
112+
- [Day 9](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day09)
113+
- [Day 10](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day10)
114+
- [Day 11](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day11)
115+
- [Day 12](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day12)
116+
- [Day 13](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day13)
117+
- [Day 14](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day14)
118+
- [Day 15](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day15)
119+
- [Day 16](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day16)
120+
- [Day 17](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day17)
121+
- [Day 18](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day18)
122+
- [Day 19](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day19)
123+
- [Day 20](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day20)
124+
- [Day 21](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day21)
125+
- [Day 22](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day22)
126+
- [Day 23](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day23)
127+
- [Day 24](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day24)
128+
- [Day 25](https://github.com/Flashky/advent-of-code-{year}/tree/master/src/main/java/com/adventofcode/flashk/day25)
129+
130+
## Cloning this repository
131+
132+
Without data repository:
133+
134+
```bash
135+
git clone https://github.com/Flashky/advent-of-code-{year}.git
136+
```
137+
138+
Including data repository:
139+
140+
```bash
141+
git clone https://github.com/Flashky/advent-of-code-{year}.git --recurse-submodules
142+
```
143+
144+
## About
145+
146+
- [Advent of Code](https://adventofcode.com/{year}/about)

0 commit comments

Comments
 (0)