Skip to content

Commit

Permalink
12
Browse files Browse the repository at this point in the history
  • Loading branch information
garethahealy committed Jan 5, 2024
1 parent dcb2cf0 commit 53c028d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 25 deletions.
67 changes: 60 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -44,4 +78,23 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3
with:
category: "/language:java"
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
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-picocli</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.githubapi</groupId>
<artifactId>quarkus-github-api</artifactId>
Expand Down
1 change: 1 addition & 0 deletions src/main/docker/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"v1.0.0"}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53c028d

Please sign in to comment.