Skip to content

Commit

Permalink
Spring Forge Update (#1)
Browse files Browse the repository at this point in the history
* spring forge initial commit

* add pcalouche github registry

* another permission change

* more repository config

* misc polish
  • Loading branch information
pcalouche authored Aug 1, 2024
1 parent c804490 commit 87dc4d1
Show file tree
Hide file tree
Showing 22 changed files with 320 additions and 686 deletions.
6 changes: 6 additions & 0 deletions .githooks/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# update git's index (bc they get messy with the pre-commit hook) according to
# https://prettier.io/docs/en/precommit.html
# see also https://github.com/prettier/prettier/issues/2978
git update-index -g
14 changes: 14 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

echo "Running pre-commit hook: formatting files"

FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0

# Apply formatting to all files
make format

# Add back the formatted files to staging
echo "$FILES" | xargs git add

exit 0
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
registries:
github:
type: "maven-repository"
url: "https://maven.pkg.github.com/pcalouche/*"
username: ${{ github.actor }}
password: ${{ github.token }}
updates:
- package-ecosystem: "maven"
directory: "/"
registries: "*"
schedule:
interval: "daily"
target-branch: "main"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
target-branch: "main"
35 changes: 35 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Continuous Integration

on:
push:
branches-ignore:
- main

permissions:
contents: read
packages: read

concurrency:
group: "${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }}"
cancel-in-progress: true

jobs:
build-and-run-tests:
name: Build and Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
show-progress: false
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Run Maven
run: mvn -B clean verify
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
63 changes: 41 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
HELP.md
/target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
# Heavily influenced by https://www.toptal.com/developers/gitignore?templates=java,jetbrains,macos

### Additional inclusions and exclusions specific to this project ###

### Java ###
# Compiled class file
*.class

# Log file
*.log

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

### Maven ###
target/
# flatten-maven-plugin
.flattened-pom.xml

### JetBrains ###
.idea/*
!.idea/codeStyles
!.idea/runConfigurations
*.iws
*.iml
*.ipr
out/

### VS Code ###
.vscode/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
/build/
### macOS ###
.DS_Store
.AppleDouble
.LSOverride
21 changes: 21 additions & 0 deletions .idea/runConfigurations/SpringSkeleton__Default_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .mvn/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
Binary file removed .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 0 additions & 18 deletions .mvn/wrapper/maven-wrapper.properties

This file was deleted.

47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Format the code
.PHONY: format
format:
mvn spotless:apply spring-javaformat:apply

# Run tests and verify
.PHONY: mvn-verify
mvn-verify: format
mvn clean verify

# Skip tests and verify
.PHONY: mvn-verify-skip-tests
mvn-verify-skip-tests: format
mvn clean verify -DskipTests

# Run tests and install locally
.PHONY: mvn-install
mvn-install: format
mvn clean install

# Skip tests and install locally
.PHONY: mvn-install-skip-tests
mvn-install-skip-tests: format
mvn clean install -DskipTests

# Check if version is a SNAPSHOT
.PHONY: check-if-snapshot-version
check-if-snapshot-version:
version="$(shell mvn help:evaluate -Dexpression=spring-enzymes.version -q -DforceStdout)" ; \
echo "version is $$version" ; \
if [[ $$version == *-SNAPSHOT ]]; then \
echo "Release version is a SNAPSHOT, so manual deploy can proceed." ; \
else \
echo "Release version is NOT a SNAPSHOT. Use a SNAPSHOT version to deploy or deploy with GitHub Actions CD." ; \
exit 1 ; \
fi

# Run tests and deploy SNAPSHOT version
.PHONY: mvn-deploy-snapshot
mvn-deploy-snapshot: check-if-snapshot-version format
mvn clean deploy

# Skip tests and deploy SNAPSHOT version
.PHONY: mvn-deploy-snapshot-skip-tests
mvn-deploy-snapshot-skip-tests: check-if-snapshot-version format
mvn clean deploy -DskipTests

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## Spring Skeleton

Spring Skeleton is a sample project to showcase the [Spring Elixir Library](https://github.com/pcalouche/springelixir) that uses Spring
Spring Skeleton is a sample project to showcase the [Spring Forge Library](https://github.com/pcalouche/spring-forge) that uses Spring
Auto-configuration to help with the configuration of some things.

Spring Elixir provides a status endpoint, standard controller advice exception handling, and Open Api documentation configured. Running this application and
Spring Forge provides a status endpoint, standard controller advice exception handling, and Open Api documentation configured. Running this application and
going to [localhost:8080/swagger-ui.html](localhost:8080/swagger-ui.html) will display the Open Api documentation. From there you'll see two endpoints:

1. /status - Demonstrates the status endpoint that is auto-configured by Spring Elixir.
1. /exception-test - Demonstrates and endpoint that will throw and exception. The JSON response returned is derived from the code in Spring Elixir.
1. /status - Demonstrates the status endpoint that is auto-configured by Spring Forge.
2. /exception-test - Demonstrates and endpoint that will throw and exception. The JSON response returned is derived from the code in Spring Forge.

Loading

0 comments on commit 87dc4d1

Please sign in to comment.