From a93466daa1064b952291ee2dc600f45e06b3ae71 Mon Sep 17 00:00:00 2001 From: Alina Zacaria Date: Fri, 29 Nov 2024 14:20:35 -0600 Subject: [PATCH 1/2] refined line count metrics --- .github/workflows/ci.yml | 77 ++++++++++++---------------------------- 1 file changed, 23 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be95f50..ccd3913 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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 From b3a33b3950a091c30951b31b94def034eea685b5 Mon Sep 17 00:00:00 2001 From: Alina Zacaria Date: Fri, 29 Nov 2024 14:28:12 -0600 Subject: [PATCH 2/2] maven file --- pom.xml | 64 ++++++++++ target/checkstyle-cachefile | 2 + target/checkstyle-checker.xml | 177 +++++++++++++++++++++++++++ target/checkstyle-result.xml | 3 + target/maven-archiver/pom.properties | 3 + 5 files changed, 249 insertions(+) create mode 100644 pom.xml create mode 100644 target/checkstyle-cachefile create mode 100644 target/checkstyle-checker.xml create mode 100644 target/checkstyle-result.xml create mode 100644 target/maven-archiver/pom.properties diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..5e0aeca --- /dev/null +++ b/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + + com.example + loc-counting + 1.0-SNAPSHOT + jar + + Java LOC Counting + Project to count Lines of Code and run static analysis + http://example.com + + + + com.puppycrawl.tools + checkstyle + 8.45 + plugin + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.1.0 + + + + check + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + + + + + org.apache.maven.plugins + maven-clean-plugin + 3.1.0 + + + + + + 1.8 + 1.8 + + diff --git a/target/checkstyle-cachefile b/target/checkstyle-cachefile new file mode 100644 index 0000000..8e17bf1 --- /dev/null +++ b/target/checkstyle-cachefile @@ -0,0 +1,2 @@ +#Fri Nov 29 14:27:34 CST 2024 +configuration*?=2A3257BC3DFCB9863B7B6609A03404712ED001EA diff --git a/target/checkstyle-checker.xml b/target/checkstyle-checker.xml new file mode 100644 index 0000000..35826d1 --- /dev/null +++ b/target/checkstyle-checker.xml @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/target/checkstyle-result.xml b/target/checkstyle-result.xml new file mode 100644 index 0000000..7e142e4 --- /dev/null +++ b/target/checkstyle-result.xml @@ -0,0 +1,3 @@ + + + diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..e8b507f --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=loc-counting +groupId=com.example +version=1.0-SNAPSHOT