Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infra: Workflows minor refactor #118

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,48 @@
name: "Backend: PR/main build & test"

on:
push:
branches:
- main
pull_request_target:
types: ["opened", "edited", "reopened", "synchronize"]
paths:
- "api/**"
branches: [ "main" ]
paths: &backend_paths
- "pom.xml"
permissions: # TODO remove when public
- "contract/**"
- "api/**"
- "serde-api/**"

pull_request_target:
types: [ "opened", "reopened", "synchronize" ]
paths: *backend_paths

permissions:
checks: write
pull-requests: write
contents: read

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ github.token }} # TODO remove when public
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
cache: 'maven'

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Build and analyze pull request target
if: ${{ github.event_name == 'pull_request' }}
env:
Expand All @@ -49,6 +59,7 @@ jobs:
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \
-Dsonar.pullrequest.branch=$HEAD_REF \
-Dsonar.pullrequest.base=$BASE_REF

- name: Build and analyze push main
if: ${{ github.event_name == 'push' }}
env:
Expand Down
43 changes: 7 additions & 36 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main ]

pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
paths:
- 'contract/**'
- 'frontend/**'
- 'api/**'
- 'serde-api/**'
- 'frontend/**'
- "pom.xml"
- "contract/**"
- 'api/**'
- 'serde-api/**'

schedule:
- cron: '39 15 * * 6'

Expand All @@ -35,25 +27,17 @@ jobs:
fail-fast: false
matrix:
language: [ 'javascript', 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ github.token }} # TODO remove when public

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Set up JDK
uses: actions/setup-java@v3
Expand All @@ -62,21 +46,8 @@ jobs:
distribution: 'zulu'
cache: 'maven'

# 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@v2

# ℹ️ 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@v2
9 changes: 6 additions & 3 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
name: "E2E: PR healthcheck"
on:
pull_request_target:
types: [ "opened", "edited", "reopened", "synchronize" ]
types: [ "opened", "reopened", "synchronize" ]
paths:
- "api/**"
- "pom.xml"
- "contract/**"
- "api/**"
- "serde-api/**"
- "frontend/**"
- "e2e-tests/**"
- "pom.xml"

permissions: # TODO remove when public
statuses: write
contents: read

jobs:
build-and-test:
runs-on: ubuntu-latest
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/frontend.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: "Frontend: PR/main build & test"
on:
push:
branches:
- main
pull_request_target:
types: ["opened", "edited", "reopened", "synchronize"]
paths:
branches: [ "main" ]
paths: &frontend_paths
- "contract/**"
- "frontend/**"

pull_request_target:
types: [ "opened", "reopened", "synchronize" ]
paths: *frontend_paths

jobs:
build-and-test:
env:
Expand Down
31 changes: 8 additions & 23 deletions .github/workflows/master.yaml → .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: "Main: Build & deploy"
on:
workflow_dispatch:

push:
branches: [ "main" ]

Expand All @@ -10,7 +11,8 @@ jobs:
permissions: # TODO remove when public
packages: write
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ github.token }} # TODO remove when public
Expand All @@ -22,18 +24,16 @@ jobs:
distribution: 'zulu'
cache: 'maven'

- name: Build
- name: Build a jar
id: build
run: |
./mvnw -B -ntp versions:set -DnewVersion=$GITHUB_SHA
./mvnw -V -B -ntp clean package -Pprod -DskipTests
export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
#################
# #
# Docker images #
# #
#################

# docker images

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand All @@ -55,7 +55,7 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
- name: Build & push docker image
id: docker_build_and_push
uses: docker/build-push-action@v5
with:
Expand All @@ -71,18 +71,3 @@ jobs:
JAR_FILE=api-${{ steps.build.outputs.version }}.jar
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
#################################
# #
# Main image digest update #
# #
#################################
- name: update-master-deployment
run: |
git clone https://infra-tech:${{ secrets.INFRA_USER_ACCESS_TOKEN }}@github.com/kafbat/ui-infra.git --branch main
cd kafka-ui-infra/aws-infrastructure4eks/argocd/scripts
echo "Image digest is:${{ steps.docker_build_and_push.outputs.digest }}"
./kafka-ui-update-master-digest.sh ${{ steps.docker_build_and_push.outputs.digest }}
git config --global user.email "[email protected]"
git config --global user.name "infra-tech"
git add ../kafka-ui/*
git commit -m "updated master image digest: ${{ steps.docker_build_and_push.outputs.digest }}" && git push
3 changes: 1 addition & 2 deletions .github/workflows/release_drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: "Infra: Release Drafter run"

on:
push:
branches:
- main
branches: [ "main" ]
workflow_dispatch:
inputs:
version:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/workflow_linter.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: "Infra: Workflow linter"
on:
pull_request:
types:
- "opened"
- "reopened"
- "synchronize"
- "edited"
types: ["opened", "reopened", "synchronize"]
paths:
- ".github/workflows/**"

Expand Down
Loading