Skip to content

Commit

Permalink
Merge branch 'redhat-appstudio:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
psturc authored May 24, 2024
2 parents eb28a39 + f3b3313 commit ae71852
Show file tree
Hide file tree
Showing 34 changed files with 1,943 additions and 356 deletions.
4 changes: 4 additions & 0 deletions .github/config/commitlint/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
ignores: [(message) => /^feat(deps): bump \[.+]\(.+\) from .+ to .+\.$/m.test(message)],
}
60 changes: 37 additions & 23 deletions .github/workflows/coffee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,48 @@ name: Coffee-break
on:
schedule:
- cron: '0 0 5 * *' # This runs at 00:00 UTC on the 5th of every month
workflow_dispatch:

jobs:
build:
coffee-break:
runs-on: ubuntu-latest
container:
image: golang:1.19
container:
image: quay.io/redhat-appstudio-qe/qe-tools:latest

steps:
- name: Check out code
uses: actions/checkout@v4
with:
repository: 'redhat-appstudio/qe-tools'
- name: Check out code
uses: actions/checkout@v4
with:
repository: 'redhat-appstudio/qe-tools'
- name: Setup Go environment
uses: actions/setup-go@v5

- name: Setup Go environment
uses: actions/setup-go@v4
- name: Run Test and Send Slack Message
run: qe-tools coffee-break
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
HACBS_CHANNEL_ID: ${{ secrets.HACBS_CHANNEL_ID }}

- name: Run Test and Send Slack Message
run: go run main.go coffee-break
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
HACBS_CHANNEL_ID: ${{ secrets.HACBS_CHANNEL_ID }}
- name: Commit and push
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
git switch -c coffee-break
git add config/coffee-break/last_week.txt
git commit -m "chore: update config/coffee-break/last_week.txt"
git push -u origin HEAD
- name: Commit and push if it's not a Pull Request
run: |
git config --global --add safe.directory /__w/qe-tools/qe-tools
git init /__w/qe-tools/qe-tools
git config user.name "GitHub Action"
git config user.email "[email protected]"
git add config/coffee-break/last_week.txt
git commit -m "Update config/coffee-break/last_week.txt"
git push origin main -f
create-pr:
runs-on: ubuntu-latest
needs: coffee-break
steps:
- name: Create PR
run: |
gh pr create \
-t "chore: Add last Coffee Break" \
-b "Created automatically by a GitHub Action." \
-H coffee-break \
-B main \
-R ${{ github.repository }} \
env:
GH_TOKEN: ${{ github.token }}
4 changes: 3 additions & 1 deletion .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
- uses: wagoid/commitlint-github-action@v5
with:
configFile: .github/config/commitlint/commitlint.config.js
35 changes: 35 additions & 0 deletions .github/workflows/estimate-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Estimate-review

on: pull_request_target

permissions:
pull-requests: write

jobs:
estimate:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4
with:
repository: 'redhat-appstudio/qe-tools'

- name: Setup Go environment
uses: actions/setup-go@v5

- name: Build qe-tools
run: make build

- name: Run estimate time needed for PR review
run: |
./qe-tools estimate-review \
--owner ${{ github.repository_owner }} \
--repository ${{ github.event.repository.name }} \
--number ${{ github.event.pull_request.number }} \
--config ${{ env.CONFIG_PATH }} \
--token ${{ github.token }} \
--add-label \
--human
env:
CONFIG_PATH: 'config/estimate/config.yaml'
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '1.19'
go-version: '1.20'

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.54.2
args: -c .golang-ci.yml -v --timeout=5m
24 changes: 24 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Pre-commit checks

on:
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go environment
uses: actions/setup-go@v5

- name: Install required tools
run: |
pip install pre-commit
make bootstrap
go mod tidy
- name: Run pre-commit checks
run: make pre-commit
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: release

on:
release:
types: [ created ]

permissions:
contents: write

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: linux
goarch: amd64
goversion: "1.20"
binary_name: qe-tools
extra_files: config
44 changes: 32 additions & 12 deletions .github/workflows/slack-message.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,44 @@ name: Prow-CI
on:
schedule:
- cron: '30 3 * * *' # Runs every day at 3:30 AM UTC (9 AM IST)
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.19
image: golang:1.20

steps:
- name: Check out code
uses: actions/checkout@v4
- name: Check out code
uses: actions/checkout@v4

- name: Setup Go environment
uses: actions/setup-go@v4
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: '1.20'

- name: Run Test and Send Slack Message
run: go run main.go prowjob periodic-slack-report
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
URL: ${{ secrets.URL }}
PROW_URL: ${{ secrets.PROW_URL }}
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
- name: Fetch URL Content
run: |
latest=$(curl -s ${{ secrets.URL }})
echo "LATEST=$latest" >> $GITHUB_ENV
- name: Run Test and Store Output
run: |
go run main.go prowjob periodic-report > prowjob-output.txt
echo $PROW_URL
env:
PROW_URL: ${{ secrets.PROW_URL }}${{ env.LATEST }}

- name: Conditional Slack Message
run: |
output=$(cat prowjob-output.txt)
if [ "$output" != "Job Succeeded" ]; then
echo "Job Failed, sending Slack message."
go run main.go send-slack-message -m "$output"
else
echo "Job Succeeded, not sending Slack message."
fi
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.19.x]
go-version: [1.20.x]
os: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}
Expand All @@ -22,12 +22,15 @@ jobs:
with:
fetch-depth: 2

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: go get
run: go get ./...

- name: go mod tidy
run: go mod tidy
run: go mod tidy

- name: Run tests
run: make test
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repos:
#
# StructSlop
#
- id: go-structslop-mod
#- id: go-structslop-mod
#
# Formatters
#
Expand All @@ -39,4 +39,4 @@ repos:
# Style Checkers
#
- id: go-lint
- id: go-critic
- id: go-critic
5 changes: 5 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Path to sources
sonar.sources=.
sonar.exclusions=**/*test*, **/vendor/**, **/zz_generated.*,
# Source encoding
sonar.sourceEncoding=UTF-8
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM registry.access.redhat.com/ubi9/go-toolset:1.20.10 AS builder

COPY go.mod go.mod
COPY go.sum go.sum

RUN go mod download

COPY main.go main.go
COPY config/ config/
COPY tools/ tools/
COPY pkg/ pkg/
COPY cmd/ cmd/

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o qe-tools main.go

FROM registry.access.redhat.com/ubi9/ubi-minimal:9.3

USER 65532:65532

WORKDIR /qe-tools

COPY --from=builder /opt/app-root/src/qe-tools /usr/bin/
COPY --from=builder /opt/app-root/src/config config


Loading

0 comments on commit ae71852

Please sign in to comment.