Skip to content

Commit

Permalink
Initial attempt at Java support
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 9, 2024
1 parent 9cec474 commit 95de053
Show file tree
Hide file tree
Showing 22 changed files with 775 additions and 188 deletions.
4 changes: 4 additions & 0 deletions .codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ component_management:
name: C#
paths:
- csharp/**
- component_id: module_java
name: Java
paths:
- java/**
- component_id: module_javascript
name: JavaScript
paths:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- 'c/**'
- 'cplusplus/**'
- 'csharp/**'
- 'java/**'
- 'javascript/**'
- 'python/**'
- '!*/README.rst'
Expand Down Expand Up @@ -60,6 +61,9 @@ jobs:
- name: csharp
language: csharp
build-mode: none
- name: java
language: java-kotlin
build-mode: none
- name: javascript
language: javascript-typescript
build-mode: none
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/java-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Java Lint

on:
push:
paths:
- 'java/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Set up Git
run: git config --global user.email "[email protected]" && git config --global user.name "GitHub Actions"

- name: Checkout code
uses: actions/checkout@v3

- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'adopt'

- name: Build with Maven
run: make ja_dependencies

- name: Run linter
run: make ja_lint

- name: Check for differences
run: |
# Get the diff from the last commit to the current working tree
if [ -n "$(git diff HEAD)" ]; then
echo "There are changes detected:"
git diff HEAD
exit 1
else
echo "No changes detected."
fi
47 changes: 47 additions & 0 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Java

on:
push:
paths:
- 'java/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest']
java-version: [8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
include:
- os: windows-latest
java-version: 21
- os: macos-latest
java-version: 21

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'adopt'

- name: Build with Maven
run: make ja_dependencies

- name: Run tests
run: make ja_test

- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: Java
1 change: 1 addition & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- '**/*.cpp'
- '**/*.cs'
- '**/*.h'
- '**/*.java'
- '**/*.js'
- '**/*.py'
- '**/*.rs'
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ help:
@echo
@echo "The following jobs are available under the cs_ prefix"
@$(MAKE) cs_help $(MFLAGS) --no-print-directory
# @echo
# @echo "The following jobs are available under the ja_ prefix"
# @$(MAKE) ja_help $(MFLAGS) --no-print-directory
@echo
@echo "The following jobs are available under the ja_ prefix"
@$(MAKE) ja_help $(MFLAGS) --no-print-directory
@echo
@echo "The following jobs are available under the js_ prefix"
@$(MAKE) js_help $(MFLAGS) --no-print-directory
Expand Down Expand Up @@ -54,8 +54,8 @@ c_%:
docs_%:
@cd docs && $(MAKE) $* $(MFLAGS)

# ja_%:
# @cd java && $(MAKE) $* $(MFLAGS)
ja_%:
@cd java && $(MAKE) $* $(MFLAGS)

js_%:
@cd javascript && $(MAKE) $* $(MFLAGS)
Expand Down
23 changes: 12 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Olivia's Project Euler Solutions
:target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/csharp.yml
.. |C#-lint| image:: https://img.shields.io/github/actions/workflow/status/LivInTheLookingGlass/Euler/csharp-lint.yml?logo=github&label=Linting
:target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/csharp-lint.yml
.. |Javai| image:: https://img.shields.io/github/actions/workflow/status/LivInTheLookingGlass/Euler/java.yml?logo=github&label=Java%20Tests
:target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/java.yml
.. |Java-lint| image:: https://img.shields.io/github/actions/workflow/status/LivInTheLookingGlass/Euler/java-lint.yml?logo=github&label=Linting
:target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/java-lint.yml
.. |JavaScript| image:: https://img.shields.io/github/actions/workflow/status/LivInTheLookingGlass/Euler/javascript.yml?logo=github&label=Js%20Tests
:target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/javascript.yml
.. |ESLint| image:: https://img.shields.io/github/actions/workflow/status/LivInTheLookingGlass/Euler/eslint.yml?logo=github&label=ESLint
Expand All @@ -33,6 +37,8 @@ Olivia's Project Euler Solutions
:target: https://app.codecov.io/github/LivInTheLookingGlass/Euler?flags%5B0%5D=Cpp
.. |Cs-Cov| image:: https://img.shields.io/codecov/c/github/LivInTheLookingGlass/Euler?flag=Csharp&logo=codecov&label=C%23%20Cov
:target: https://app.codecov.io/github/LivInTheLookingGlass/Euler?flags%5B0%5D=Csharp
.. |Ja-Cov| image:: https://img.shields.io/codecov/c/github/LivInTheLookingGlass/Euler?flag=Java&logo=codecov&label=Java%20Cov
:target: https://app.codecov.io/github/LivInTheLookingGlass/Euler?flags%5B0%5D=Java
.. |Js-Cov| image:: https://img.shields.io/codecov/c/github/LivInTheLookingGlass/Euler?flag=JavaScript&logo=codecov&label=Js%20Cov
:target: https://app.codecov.io/github/LivInTheLookingGlass/Euler?flags%5B0%5D=JavaScript
.. |Py-Cov| image:: https://img.shields.io/codecov/c/github/LivInTheLookingGlass/Euler?flag=Python&logo=codecov&label=Py%20Cov
Expand Down Expand Up @@ -67,6 +73,11 @@ Olivia's Project Euler Solutions
| | | | |CodeQL| |br| |
| | | | |C#-lint| |
+------------+--------------------------+--------+-------------------+
| Java | Java 8+ | 2 | |Javai| |br| |
| | | | |Ja-Cov| |br| |
| | | | |CodeQL| |br| |
| | | | |Java-lint| |
+------------+--------------------------+--------+-------------------+
| JavaScript | Node 12+ |br| | 20 | |JavaScript| |br| |
| | Bun 1.0+ |br| | | |Js-Cov| |br| |
| | Firefox [2]_ |br| | | |CodeQL| |br| |
Expand Down Expand Up @@ -124,21 +135,11 @@ Makefile will direct recipes using prefixes
- ``make cp_*`` will go to the csharp Makefile
- ``make cs_*`` will go to the csharp Makefile
- ``make docs_*`` will go to the docs Makefile
- ``make ja_*`` will go to the java Makefile
- ``make js_*`` will go to the javascript Makefile
- ``make py_*`` will go to the python Makefile
- ``make rs_*`` will go to the rust Makefile
- Any make recipes supported by Sphinx will be redirected to the docs Makefile
- All other recipes will be run for all languages

For more information, please see the README documents in each section.

Roadmap
-------

1. Make sure no language is below Makefile in code percentage
2. For each language in: Ruby, ...
a. Create a new section
b. Make stubs for test code
c. Write minimal documentation
d. Port problems 1-n, until higher than Makefile percentage
e. Repeat step 1
12 changes: 12 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,15 @@ def setup(app):
}
))

app.add_domain(custom_domain(
'JavaDomain',
'java',
'Java',
{
'class': {
},
'method': {
},
}
))

4 changes: 2 additions & 2 deletions docs/csharp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Euler C# Implementation
:start-line: 2
:end-before: Makefile

.. include:: ../rust/README.rst
:start-after: Alias for ``cargo clean``
.. include:: ../csharp/README.rst
:start-after: dependencies for this section.
:end-before: Problems Solved

Usage
Expand Down
Loading

0 comments on commit 95de053

Please sign in to comment.