Skip to content

Commit

Permalink
refined line count metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
alina-z7 committed Nov 29, 2024
1 parent 8068f04 commit a93466d
Showing 1 changed file with 23 additions and 54 deletions.
77 changes: 23 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Java Swing CI with MySQL
name: Java CI with LOC Counting

# Trigger the workflow on pushes to main and pull requests to main
on:
push:
branches:
Expand All @@ -10,64 +9,34 @@ on:
- main

jobs:
ci:
build:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: test_db
MYSQL_USER: user
MYSQL_PASSWORD: user_password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=30s
--health-timeout=5s
--health-retries=3
steps:
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# Step 2: Set up Java Development Kit (JDK)
- name: Set up JDK 11
uses: actions/setup-java@v3
# Checkout the code
- name: Checkout code
uses: actions/checkout@v2
# Cache Maven dependencies
- name: Cache Maven dependencies
uses: actions/cache@v2
with:
java-version: '11'
distribution: 'adoptopenjdk'

# Step 3: Install MySQL client (if needed for testing connection)
- name: Install MySQL client
run: sudo apt-get install mysql-client
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/*.java') }}
restore-keys: |
${{ runner.os }}-maven-
# Step 4: Build the Java application with Maven or Gradle
# Build with Maven (check for compilation errors)
- name: Build with Maven
run: mvn clean install

# Run Checkstyle (static code analysis)
- name: Run Checkstyle
run: mvn checkstyle:check

# Step 5: Run tests (unit tests and integration tests)
- name: Run tests
run: mvn test

# Step 6: (Optional) Package your app into a JAR file
- name: Package application
run: mvn package

# Step 7: Run integration tests with MySQL
- name: Run integration tests with MySQL
# Count Lines of Code using cloc
- name: Count Lines of Code
run: |
echo "Waiting for MySQL to be ready..."
sleep 30 # Wait for MySQL to be ready (or use a better method for health check)
mvn verify -P integration-tests
# Secrets can be used for sensitive data like MySQL password and username.
env:
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
MYSQL_USER: user
MYSQL_PASSWORD: user_password
MYSQL_DB: test_db
sudo apt-get update
sudo apt-get install -y cloc
cloc --exclude-dir=target --quiet . # Exclude 'target' directory to avoid counting compiled files

0 comments on commit a93466d

Please sign in to comment.