Skip to content

Commit 2ef5d0b

Browse files
Copilotgkorland
andauthored
Add GitHub Actions CI workflows for build, tests, and Maven publishing (#2)
* Initial plan * Add GitHub Actions workflows for CI/CD Co-authored-by: gkorland <[email protected]> * Add CI/CD documentation and update README Co-authored-by: gkorland <[email protected]> * Enhance workflows with permissions, concurrency, and summaries Co-authored-by: gkorland <[email protected]> * Add GitHub Actions workflows quick reference guide Co-authored-by: gkorland <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: gkorland <[email protected]>
1 parent a136eb4 commit 2ef5d0b

File tree

5 files changed

+483
-0
lines changed

5 files changed

+483
-0
lines changed

.github/WORKFLOWS.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# GitHub Actions Workflows Quick Reference
2+
3+
This document provides a quick reference for the GitHub Actions workflows in this repository.
4+
5+
## Workflows Overview
6+
7+
| Workflow | File | Triggers | Purpose |
8+
|----------|------|----------|---------|
9+
| Build & Test | `build.yml` | PR, Push to main/release | Validate code changes |
10+
| Publish to Maven | `publish.yml` | Push to main/release, Manual | Deploy SNAPSHOT artifacts |
11+
| CodeQL | `codeql.yml` | PR, Push, Schedule | Security analysis |
12+
| Project Management | `project.yml` | Issues, PR events | Automate issue tracking |
13+
14+
## Build & Test Workflow
15+
16+
### When it runs
17+
- On pull requests to `main` or release branches (`X.X.x`)
18+
- On pushes to `main` or release branches
19+
20+
### What it does
21+
1. Checks out code
22+
2. Sets up Java 17 (Temurin)
23+
3. Starts FalkorDB service (port 6379)
24+
4. Runs Maven build with tests and checkstyle
25+
5. Uploads test results
26+
6. Publishes test report
27+
28+
### Environment
29+
- **Java**: 17
30+
- **Maven**: Via wrapper
31+
- **FalkorDB**: Latest (Docker service)
32+
33+
### Required Secrets
34+
None
35+
36+
### Configuration
37+
Modify `build.yml` to:
38+
- Change Java version: Update `java-version` in setup-java step
39+
- Adjust FalkorDB version: Update `image` in services section
40+
- Customize Maven goals: Edit `run` in "Build with Maven" step
41+
42+
## Publish to Maven Workflow
43+
44+
### When it runs
45+
- On pushes to `main` or release branches
46+
- Manually via workflow_dispatch
47+
48+
### What it does
49+
1. Checks out code
50+
2. Sets up Java 17 (Temurin)
51+
3. Starts FalkorDB service for tests
52+
4. Builds and deploys to Maven repository
53+
5. Uploads build artifacts
54+
55+
### Environment
56+
- **Java**: 17
57+
- **Maven**: Via wrapper with settings.xml
58+
- **FalkorDB**: Latest (Docker service)
59+
60+
### Required Secrets
61+
- `ARTIFACTORY_USERNAME` - Maven repository username
62+
- `ARTIFACTORY_PASSWORD` - Maven repository password/token
63+
64+
### Configuration
65+
Modify `publish.yml` to:
66+
- Change deployment target: Update `settings.xml` in project root
67+
- Adjust artifact retention: Change `retention-days` in Upload Artifacts step
68+
- Customize Maven goals: Edit `run` in "Build and Deploy" step
69+
70+
## Manual Workflow Dispatch
71+
72+
To manually trigger the Publish workflow:
73+
74+
1. Go to Actions tab in GitHub
75+
2. Select "Publish to Maven" workflow
76+
3. Click "Run workflow"
77+
4. Select branch (usually `main`)
78+
5. Click "Run workflow" button
79+
80+
## Workflow Status
81+
82+
View workflow status at:
83+
- Repository Actions tab: `https://github.com/FalkorDB/spring-data-falkordb/actions`
84+
- Pull requests: Status checks section
85+
- Commits: Commit status icons
86+
87+
## Troubleshooting
88+
89+
### Build Failures
90+
91+
**Problem**: Tests fail with "Connection refused" to FalkorDB
92+
- **Cause**: FalkorDB service not ready
93+
- **Solution**: Health check should handle this automatically; if persists, increase health check retries in workflow
94+
95+
**Problem**: Maven dependency resolution fails
96+
- **Cause**: Network issues or repository unavailable
97+
- **Solution**: Retry the workflow; GitHub Actions will use cached dependencies if available
98+
99+
**Problem**: Checkstyle failures
100+
- **Cause**: Code style violations
101+
- **Solution**: Run `./mvnw spring-javaformat:apply` locally to fix formatting
102+
103+
### Publish Failures
104+
105+
**Problem**: Authentication error deploying to Maven repository
106+
- **Cause**: Missing or incorrect secrets
107+
- **Solution**: Verify `ARTIFACTORY_USERNAME` and `ARTIFACTORY_PASSWORD` secrets in repository settings
108+
109+
**Problem**: "Version already exists" error
110+
- **Cause**: Trying to publish non-SNAPSHOT version
111+
- **Solution**: This workflow only publishes SNAPSHOT versions; use a release workflow for releases
112+
113+
## Best Practices
114+
115+
### For Contributors
116+
117+
1. **Before opening PR**: Run `./mvnw clean verify` locally
118+
2. **Fix issues quickly**: CI failures block merging
119+
3. **Check test reports**: Review failed tests in Actions tab
120+
4. **Keep PRs focused**: Smaller PRs are easier to review and test
121+
122+
### For Maintainers
123+
124+
1. **Monitor workflow runs**: Check Actions tab regularly
125+
2. **Update secrets**: Rotate credentials periodically
126+
3. **Review dependencies**: Update action versions in workflows
127+
4. **Cache management**: Clear caches if build issues persist
128+
129+
## Workflow Files Location
130+
131+
All workflow files are in `.github/workflows/`:
132+
```
133+
.github/workflows/
134+
├── build.yml # Build & Test
135+
├── publish.yml # Publish to Maven
136+
├── codeql.yml # CodeQL security scan
137+
└── project.yml # Project management
138+
```
139+
140+
## Related Documentation
141+
142+
- [CI README](../ci/README.md) - Detailed CI/CD documentation
143+
- [Contributing Guide](../README.md#-contributing) - How to contribute
144+
- [Maven Documentation](https://maven.apache.org/) - Maven reference
145+
- [GitHub Actions Docs](https://docs.github.com/actions) - GitHub Actions reference
146+
147+
## Getting Help
148+
149+
- Open an issue in the repository
150+
- Check the Actions tab for workflow run logs
151+
- Review the CI README for troubleshooting steps
152+
- Contact maintainers via email or Discord

.github/workflows/build.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# GitHub Actions workflow for Build & Tests
2+
name: Build & Test
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- '[0-9]+.[0-9]+.x'
9+
pull_request:
10+
branches:
11+
- main
12+
- '[0-9]+.[0-9]+.x'
13+
14+
permissions:
15+
contents: read
16+
checks: write
17+
pull-requests: write
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
22+
23+
jobs:
24+
build:
25+
name: Build and Test
26+
runs-on: ubuntu-latest
27+
28+
services:
29+
falkordb:
30+
image: falkordb/falkordb:latest
31+
ports:
32+
- 6379:6379
33+
options: >-
34+
--health-cmd "redis-cli ping"
35+
--health-interval 10s
36+
--health-timeout 5s
37+
--health-retries 5
38+
39+
steps:
40+
- name: Check out code
41+
uses: actions/checkout@v4
42+
43+
- name: Set up JDK 17
44+
uses: actions/setup-java@v4
45+
with:
46+
java-version: '17'
47+
distribution: 'temurin'
48+
cache: 'maven'
49+
50+
- name: Build with Maven
51+
run: |
52+
./mvnw -s settings.xml clean verify -U -B -Dcheckstyle.skip=false -Dmaven.javadoc.skip=true
53+
echo "### Build Summary :rocket:" >> $GITHUB_STEP_SUMMARY
54+
echo "Build completed successfully!" >> $GITHUB_STEP_SUMMARY
55+
echo "- Java Version: 17" >> $GITHUB_STEP_SUMMARY
56+
echo "- FalkorDB Version: latest" >> $GITHUB_STEP_SUMMARY
57+
env:
58+
SDF_FALKORDB_VERSION: latest
59+
60+
- name: Upload Test Results
61+
if: always()
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: test-results
65+
path: |
66+
**/target/surefire-reports/*.xml
67+
**/target/failsafe-reports/*.xml
68+
retention-days: 7
69+
70+
- name: Publish Test Report
71+
if: always()
72+
uses: dorny/test-reporter@v1
73+
with:
74+
name: Maven Tests
75+
path: '**/target/surefire-reports/*.xml,**/target/failsafe-reports/*.xml'
76+
reporter: java-junit
77+
fail-on-error: true

.github/workflows/publish.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# GitHub Actions workflow for Publishing to Maven Repository
2+
name: Publish to Maven
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- '[0-9]+.[0-9]+.x'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: publish-${{ github.ref }}
16+
cancel-in-progress: false
17+
18+
jobs:
19+
publish:
20+
name: Publish SNAPSHOT to Maven
21+
runs-on: ubuntu-latest
22+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
23+
24+
services:
25+
falkordb:
26+
image: falkordb/falkordb:latest
27+
ports:
28+
- 6379:6379
29+
options: >-
30+
--health-cmd "redis-cli ping"
31+
--health-interval 10s
32+
--health-timeout 5s
33+
--health-retries 5
34+
35+
steps:
36+
- name: Check out code
37+
uses: actions/checkout@v4
38+
39+
- name: Set up JDK 17
40+
uses: actions/setup-java@v4
41+
with:
42+
java-version: '17'
43+
distribution: 'temurin'
44+
cache: 'maven'
45+
46+
- name: Build and Deploy to Maven Repository
47+
run: |
48+
./mvnw -s settings.xml clean deploy -U -B -Dcheckstyle.skip=true -Dmaven.javadoc.skip=false
49+
echo "### Publish Summary :package:" >> $GITHUB_STEP_SUMMARY
50+
echo "Successfully published artifacts to Maven repository!" >> $GITHUB_STEP_SUMMARY
51+
echo "- Version: 1.0.0-SNAPSHOT" >> $GITHUB_STEP_SUMMARY
52+
echo "- Branch: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
53+
env:
54+
SDF_FALKORDB_VERSION: latest
55+
ARTIFACTORY_USR: ${{ secrets.ARTIFACTORY_USERNAME }}
56+
ARTIFACTORY_PSW: ${{ secrets.ARTIFACTORY_PASSWORD }}
57+
58+
- name: Upload Artifacts
59+
if: success()
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: maven-artifacts
63+
path: |
64+
target/*.jar
65+
target/*.pom
66+
retention-days: 30

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Spring Data FalkorDB
22

3+
[![Build & Test](https://github.com/FalkorDB/spring-data-falkordb/actions/workflows/build.yml/badge.svg)](https://github.com/FalkorDB/spring-data-falkordb/actions/workflows/build.yml)
34
[![Maven Central](https://img.shields.io/maven-central/v/org.springframework.data/spring-data-falkordb.svg)](https://search.maven.org/artifact/org.springframework.data/spring-data-falkordb)
45
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
56
[![Java Version](https://img.shields.io/badge/Java-17+-brightgreen.svg)](https://openjdk.java.net/projects/jdk/17/)
@@ -708,6 +709,19 @@ mvn clean compile
708709
mvn test
709710
```
710711

712+
### CI/CD
713+
714+
This project uses GitHub Actions for continuous integration and deployment:
715+
716+
- **Build & Test**: Automatically runs on all PRs and pushes to main/release branches
717+
- Validates code with checkstyle
718+
- Runs full test suite with FalkorDB integration tests
719+
- Publishes test reports
720+
721+
- **Publish**: Automatically publishes SNAPSHOT artifacts to Maven repository on merges to main
722+
723+
See [ci/README.md](ci/README.md) for detailed CI/CD documentation.
724+
711725
### Areas Needing Help
712726

713727
- [ ] Query method parsing and generation

0 commit comments

Comments
 (0)