From f9abc179eddda925e74abcb937da2441e30e921c Mon Sep 17 00:00:00 2001 From: Max Cao Date: Mon, 14 Aug 2023 06:24:48 -0700 Subject: [PATCH] feat(ci): add simple workflows (#49) --- .github/workflows/ci.yaml | 100 ++++++++++++++++++ .github/workflows/dependent-issues.yml | 28 +++++ .github/workflows/pr-labeled.yml | 19 ++++ README.md | 3 + .../java/itest/bases/StandardSelfTest.java | 12 +-- 5 files changed, 156 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/dependent-issues.yml create mode 100644 .github/workflows/pr-labeled.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..4f6ec630c --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,100 @@ +name: CI build and push + +concurrency: + group: ci-${{ github.run_id }} + cancel-in-progress: true + +on: + push: + branches: + - main + - v[0-9]+ + - v[0-9]+.[0-9]+ + - cryostat-v[0-9]+.[0-9]+ + pull_request_target: + types: + - opened + - reopened + - synchronize + - labeled + - unlabeled + branches: + - main + - v[0-9]+ + - v[0-9]+.[0-9]+ + - cryostat-v[0-9]+.[0-9]+ + +jobs: + build-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + java: [ '17', '20' ] + env: + TESTCONTAINERS_RYUK_DISABLED: true + cache-name: cache-yarn + name: Build and test Java ${{ matrix.java }} + permissions: + packages: write + contents: read + if: ${{ github.repository_owner == 'cryostatio' }} + steps: + # - name: Fail if PR and safe-to-test label NOT applied + # if: ${{ github.event_name == 'pull_request_target' && !contains(github.event.pull_request.labels.*.name, 'safe-to-test') }} + # run: exit 1 + - uses: actions/checkout@v3 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + submodules: true + fetch-depth: 0 + - uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: 'maven' + - name: maven-settings + uses: s4u/maven-settings-action@v2 + with: + servers: '[{"id": "github", "username": "dummy", "password": "${{ secrets.GITHUB_TOKEN }}"}]' + githubServer: false + - run: git submodule init && git submodule update + - name: Cache yarn packages + uses: actions/cache@v3 + with: + path: "./src/main/webui/.yarn/cache" + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Initialize web assets + run: | + cd src/main/webui + yarn install && yarn yarn:frzinstall + cd - + - name: Update podman + run: | + sudo apt-get -y purge podman + sudo mkdir -p /etc/apt/keyrings + curl -fsSL https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_$(lsb_release -rs)/Release.key | gpg --dearmor | sudo tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg] \ + https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_$(lsb_release -rs)/ /" \ + | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null + sudo apt-get update -qq + sudo apt-get -qq -y install podman + - name: Install podman-docker + run: | + sudo apt-get -y purge moby-cli + sudo apt install -y podman-docker + - name: Setup docker host + run: echo "DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock" >> "$GITHUB_ENV" + - name: Set up testcontainers for podman + run: | + echo ryuk.container.privileged=true > ~/.testcontainers.properties + - run: systemctl --user enable --now podman.socket + - name: Build db image + run: sh db/build.sh + - name: Run tests + run: ./mvnw -B -U clean verify diff --git a/.github/workflows/dependent-issues.yml b/.github/workflows/dependent-issues.yml new file mode 100644 index 000000000..6cd682113 --- /dev/null +++ b/.github/workflows/dependent-issues.yml @@ -0,0 +1,28 @@ +name: Dependent Issues + +on: + pull_request_target: + types: + - opened + - edited + - reopened + - synchronize + + # Schedule a daily check. Used in referencing cross-repository + # issues or pull requests + schedule: + - cron: '0 0 * * *' + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: z0al/dependent-issues@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # (Optional) Enable checking for dependencies in issues. + # Enable by setting the value to "on". Default "off" + check_issues: off + + keywords: depends on, blocked by, based on diff --git a/.github/workflows/pr-labeled.yml b/.github/workflows/pr-labeled.yml new file mode 100644 index 000000000..102c185d6 --- /dev/null +++ b/.github/workflows/pr-labeled.yml @@ -0,0 +1,19 @@ +name: Require semantic labels + +on: + pull_request: + types: + - opened + - labeled + - unlabeled + - synchronize + +jobs: + check-pr-label-and-comment: + runs-on: ubuntu-latest + steps: + - uses: yashhy/pr-label-check-and-comment-action@v1.0.1 + with: + # This list is duplicated from release-drafter.yml + required_labels: 'chore,ci,cleanup,docs,feat,fix,perf,refactor,style,test' + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 7c8478a2b..c2762ed71 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Cryostat3 +[![CI build and push](https://github.com/cryostatio/cryostat3/actions/workflows/ci.yaml/badge.svg)](https://github.com/cryostatio/cryostat3/actions/workflows/ci.yaml) +[![Google Group : Cryostat Development](https://img.shields.io/badge/Google%20Group-Cryostat%20Development-blue.svg)](https://groups.google.com/g/cryostat-development) + This project uses Quarkus, the Supersonic Subatomic Java Framework. If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . diff --git a/src/test/java/itest/bases/StandardSelfTest.java b/src/test/java/itest/bases/StandardSelfTest.java index 3d4714e84..01fcf89fe 100644 --- a/src/test/java/itest/bases/StandardSelfTest.java +++ b/src/test/java/itest/bases/StandardSelfTest.java @@ -64,10 +64,10 @@ public abstract class StandardSelfTest { public static void waitForJdp() { Logger logger = Logger.getLogger(StandardSelfTest.class); boolean found = false; - long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(15); + long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(30); + String selfURL = getSelfReferenceConnectUrl(); while (!found && System.nanoTime() < deadline) { - logger.infov( - "Waiting for self-discovery at {0} via JDP...", getSelfReferenceConnectUrl()); + logger.infov("Waiting for self-discovery at {0} via JDP...", selfURL); CompletableFuture queryFound = new CompletableFuture<>(); ForkJoinPool.commonPool() .submit( @@ -90,11 +90,11 @@ public static void waitForJdp() { arr.getJsonObject(0) .getString( "connectUrl"), - getSelfReferenceConnectUrl())); + selfURL)); }); }); try { - found |= queryFound.get(500, TimeUnit.MILLISECONDS); + found |= queryFound.get(1000, TimeUnit.MILLISECONDS); Thread.sleep(1000); } catch (InterruptedException | ExecutionException | TimeoutException e) { logger.warn(e); @@ -169,7 +169,7 @@ public static String getSelfReferenceConnectUrl() { }); }); }); - String hostname = hostnameFuture.get(2, TimeUnit.SECONDS); + String hostname = hostnameFuture.get(5, TimeUnit.SECONDS); return String.format("service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi", hostname, 9091); } catch (InterruptedException | ExecutionException | TimeoutException e) {