diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..95fc538 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,54 @@ +name: "CodeQL" + +on: + push: + branches: [master, ] + pull_request: + # The branches below must be a subset of the branches above + branches: [master] + schedule: + - cron: '0 12 * * 5' + +jobs: + analyse: + name: Analyse + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + # Override language selection by uncommenting this and choosing your languages + with: + languages: java # go, javascript, csharp, python, cpp, java + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 6f27edc..56b699d 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,6 +1,6 @@ name: Java CI -on: [push] +on: push jobs: build: diff --git a/.m2/settings.xml b/.m2/settings.xml index 5ad9701..fc03aad 100644 --- a/.m2/settings.xml +++ b/.m2/settings.xml @@ -19,8 +19,8 @@ github - GitHub Apache Maven Packages - https://maven.pkg.github.com/Gazetteer-Panda + GitHub OWNER Apache Maven Packages + https://maven.pkg.github.com/PramodhMDT/sunshine-action @@ -29,8 +29,8 @@ github - Actions - TOKEN + PramodhMDT + ${env.GITHUB_TOKEN} diff --git a/README.md b/README.md index b69549f..a7dbb7e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ +![CodeQL](https://github.com/PramodhMDT/JavaTestDemo/workflows/CodeQL/badge.svg?branch=master) + # This is sample math application ## Given a number n, finds the sum of numbers from 1 to n Edited by Pramodh Kumar M -Added One Line diff --git a/azure-pipelines-1.yml b/azure-pipelines-1.yml new file mode 100644 index 0000000..c8b3f0a --- /dev/null +++ b/azure-pipelines-1.yml @@ -0,0 +1,31 @@ +# Maven +# Build your Java project and run tests with Apache Maven. +# Add steps that analyze code, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/java + +trigger: +- master + +pool: Default + +steps: +- task: Maven@3 + inputs: + mavenPomFile: 'pom.xml' + mavenOptions: '-Xmx3072m' + javaHomeOption: 'JDKVersion' + jdkVersionOption: '1.8' + jdkArchitectureOption: 'x64' + publishJUnitResults: true + testResultsFiles: '**/surefire-reports/TEST-*.xml' + goals: 'package' + +- task: CopyFiles@2 + inputs: + SourceFolder: '$(Build.SourcesDirectory)' + contents: 'target\*.jar' + targetFolder: $(Build.ArtifactStagingDirectory) +- task: PublishBuildArtifacts@1 + inputs: + pathToPublish: $(Build.ArtifactStagingDirectory) + artifactName: MyBuildOutputs \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..c83b80b --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,22 @@ +# Maven +# Build your Java project and run tests with Apache Maven. +# Add steps that analyze code, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/java + +trigger: +- master + +pool: + vmImage: ubuntu-22.04 + +steps: +- task: Maven@3 + inputs: + mavenPomFile: 'pom.xml' + #mavenOptions: '-Xmx3072m' + javaHomeOption: 'JDKVersion' + jdkVersionOption: '1.8' + jdkArchitectureOption: 'x64' + publishJUnitResults: true + testResultsFiles: '**/surefire-reports/TEST-*.xml' + goals: 'package' diff --git a/pom.xml b/pom.xml index 524e0f7..32ad7bf 100644 --- a/pom.xml +++ b/pom.xml @@ -2,11 +2,10 @@ 4.0.0 com.javatestdemo javatestdemo - 1.1.3 + 1.1.4 JavaTestDemo jar This is Java Testing Demo - http://maven.pkg.github.com/Gazetteer-Panda UTF-8 @@ -16,6 +15,25 @@ 1.8 1.8 + + + + + github + GitHub TobseF Apache Maven Packages + https://maven.pkg.github.com/TobseF/HelloMaven + true + true + + @@ -35,6 +53,12 @@ 4.12 test + @@ -72,7 +96,7 @@ github - https://maven.pkg.github.com/Gazetteer-Panda/javatestdemo + https://maven.pkg.github.com/PramodhMDT/javatestdemo true diff --git a/src/main/java/com/javatestdemo/MySum.java b/src/main/java/com/javatestdemo/MySum.java index 07dd0f8..37dbe61 100644 --- a/src/main/java/com/javatestdemo/MySum.java +++ b/src/main/java/com/javatestdemo/MySum.java @@ -1,5 +1,5 @@ package com.javatestdemo; - +//Main Class public class MySum { static int sumofnumbers (int numbers) { @@ -12,6 +12,6 @@ static int sumofnumbers (int numbers) { public static void main(String[] args) { int numbers = Integer.parseInt(args[0]); - System.out.println(sumofnumbers(numbers)); + System.out.println(sumofnumbers(numbers)); } } diff --git a/src/test/java/com/javatestdemo/MySum_Test.java b/src/test/java/com/javatestdemo/MySum_Test.java index 8b3118f..e1f156f 100644 --- a/src/test/java/com/javatestdemo/MySum_Test.java +++ b/src/test/java/com/javatestdemo/MySum_Test.java @@ -31,5 +31,13 @@ public void mySimpleTest_3() { assertEquals(Obj1.sumofnumbers(13), 91); assertEquals(Obj1.sumofnumbers(14), 105); assertEquals(Obj1.sumofnumbers(15), 120); - } + } + @Test //Test 4 + public void mySimpleTest_4() { + assertEquals(Obj1.sumofnumbers(16), 136); + assertEquals(Obj1.sumofnumbers(17), 153); + assertEquals(Obj1.sumofnumbers(18), 171); + assertEquals(Obj1.sumofnumbers(19), 190); + assertEquals(Obj1.sumofnumbers(20), 210); + } }