From 53c028d418f8f0b7a5a0edca989f665915ebb120 Mon Sep 17 00:00:00 2001 From: Gareth Healy Date: Fri, 5 Jan 2024 13:35:08 +0000 Subject: [PATCH] 12 --- .github/workflows/build.yaml | 67 +++++++++++++++++-- pom.xml | 5 -- src/main/docker/version.json | 1 + .../githubstats/GitHubStatsApplication.java | 8 +-- .../commands/CollectStatsCommand.java | 6 +- .../commands/CreateWhoAreYouIssueCommand.java | 6 +- 6 files changed, 68 insertions(+), 25 deletions(-) create mode 100644 src/main/docker/version.json diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2268629..358176d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,15 +1,12 @@ -name: "Build, Test and Analyze" +name: "Build, Analyze and Test" on: [push, pull_request] jobs: - analyze: - name: Analyze + build: runs-on: ubuntu-latest permissions: - actions: read contents: read - security-events: write steps: - name: Checkout repository @@ -18,7 +15,7 @@ jobs: - uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4 with: distribution: "temurin" - java-version: 17 + java-version: 21 - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3 with: @@ -33,6 +30,43 @@ jobs: - name: Build native run: ./mvnw clean install -Pnative --batch-mode + - name: Upload target + uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4 + with: + name: target + path: target/ + if-no-files-found: error + + - name: Get image tags + id: image_tags + uses: redhat-cop/github-actions/get-image-version@main + with: + IMAGE_CONTEXT_DIR: src/main/docker + + - name: Build image + uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2 + with: + dockerfiles: src/main/docker/Dockerfile.native-micro + image: github-stats + oci: true + tags: "${{ steps.image_tags.outputs.IMAGE_TAGS }}" + + analyze: + needs: [ build ] + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + steps: + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + + - uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4 + with: + distribution: "temurin" + java-version: 21 + - name: Initialize CodeQL uses: github/codeql-action/init@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3 with: @@ -44,4 +78,23 @@ jobs: - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3 with: - category: "/language:java" \ No newline at end of file + category: "/language:java" + + test: + needs: [ build ] + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Download target + uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4 + with: + name: target + + - name: Run help + run: target/github-stats-*-runner help + + - name: Run help + env: + GITHUB_LOGIN: ${{ secrets.GITHUB_TOKEN }} + run: target/github-stats-*-runner collect-stats --organization=garethahealy \ No newline at end of file diff --git a/pom.xml b/pom.xml index ed2698f..4f66cd0 100644 --- a/pom.xml +++ b/pom.xml @@ -38,11 +38,6 @@ io.quarkus quarkus-picocli - - org.apache.maven.shared - maven-shared-utils - 3.4.2 - io.quarkiverse.githubapi quarkus-github-api diff --git a/src/main/docker/version.json b/src/main/docker/version.json new file mode 100644 index 0000000..1f1324b --- /dev/null +++ b/src/main/docker/version.json @@ -0,0 +1 @@ +{"version":"v1.0.0"} \ No newline at end of file diff --git a/src/main/java/com/garethahealy/githubstats/GitHubStatsApplication.java b/src/main/java/com/garethahealy/githubstats/GitHubStatsApplication.java index 4c7fa18..71edfb2 100644 --- a/src/main/java/com/garethahealy/githubstats/GitHubStatsApplication.java +++ b/src/main/java/com/garethahealy/githubstats/GitHubStatsApplication.java @@ -7,7 +7,6 @@ import io.quarkus.runtime.QuarkusApplication; import io.quarkus.runtime.annotations.QuarkusMain; import jakarta.inject.Inject; -import org.apache.maven.shared.utils.cli.CommandLineUtils; import picocli.CommandLine; @QuarkusMain @@ -23,14 +22,9 @@ public static void main(String[] args) { @Override public int run(String... args) throws Exception { - if (args.length != 1) { - Quarkus.waitForExit(); - return 0; - } - return new CommandLine(new QuarkusCommand()) .addSubcommand(collectStatsCommand) .addSubcommand(createWhoAreYouIssueCommand) - .execute(CommandLineUtils.translateCommandline(args[0])); + .execute(args); } } diff --git a/src/main/java/com/garethahealy/githubstats/commands/CollectStatsCommand.java b/src/main/java/com/garethahealy/githubstats/commands/CollectStatsCommand.java index 48782a3..7ef9fa9 100644 --- a/src/main/java/com/garethahealy/githubstats/commands/CollectStatsCommand.java +++ b/src/main/java/com/garethahealy/githubstats/commands/CollectStatsCommand.java @@ -11,13 +11,13 @@ @CommandLine.Command(name = "collect-stats", mixinStandardHelpOptions = true, description = "Collect the stats in CSV format") public class CollectStatsCommand implements Runnable { - @CommandLine.Option(names = {"-org", "--organization"}, description = "GitHub organization", defaultValue = "redhat-cop") + @CommandLine.Option(names = {"-org", "--organization"}, description = "GitHub organization", required = true) String organization; - @CommandLine.Option(names = {"-cfg", "--validate-org-config"}, description = "Whether to check the 'org/config.yaml'", defaultValue = "true") + @CommandLine.Option(names = {"-cfg", "--validate-org-config"}, description = "Whether to check the 'org/config.yaml'", defaultValue = "false") boolean validateOrgConfig; - @CommandLine.Option(names = {"-o", "--csv-output"}, description = "Output location for CSV", defaultValue = "target/github-output.csv") + @CommandLine.Option(names = {"-o", "--csv-output"}, description = "Output location for CSV", defaultValue = "github-output.csv") String output; @Inject diff --git a/src/main/java/com/garethahealy/githubstats/commands/CreateWhoAreYouIssueCommand.java b/src/main/java/com/garethahealy/githubstats/commands/CreateWhoAreYouIssueCommand.java index 8c7acef..3216991 100644 --- a/src/main/java/com/garethahealy/githubstats/commands/CreateWhoAreYouIssueCommand.java +++ b/src/main/java/com/garethahealy/githubstats/commands/CreateWhoAreYouIssueCommand.java @@ -12,13 +12,13 @@ @CommandLine.Command(name = "create-who-are-you-issues", mixinStandardHelpOptions = true, description = "Creates an issue per user in the org config that isn't in a CVS") public class CreateWhoAreYouIssueCommand implements Runnable { - @CommandLine.Option(names = {"-org", "--organization"}, description = "GitHub organization", defaultValue = "redhat-cop") + @CommandLine.Option(names = {"-org", "--organization"}, description = "GitHub organization", required = true) String organization; - @CommandLine.Option(names = {"-repo", "--org-repo"}, description = "Repo name for 'org'", defaultValue = "org") + @CommandLine.Option(names = {"-repo", "--org-repo"}, description = "Repo name for 'org'", required = true) String orgRepo; - @CommandLine.Option(names = {"-dry", "--dry-run"}, description = "Dry-run aka dont actually create the GitHub issues", defaultValue = "true") + @CommandLine.Option(names = {"-dry", "--dry-run"}, description = "Dry-run aka dont actually create the GitHub issues", required = true) Boolean dryRun; @Inject