Skip to content

Commit

Permalink
Merge branch 'main' into renovate/github.com-swaggo-swag-1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
pigri authored Nov 6, 2024
2 parents fd696ad + 57e368f commit 25e675b
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 146 deletions.
Original file line number Diff line number Diff line change
@@ -1,46 +1,61 @@
name: Cache service preview
name: Cache Service Preview

on:
pull_request_review:
types: [submitted]
pull_request:
types: [opened, synchronize]
branches:
- main
paths:
- services/cache/**
- .github/workflows/cache-pull.yaml
- .github/workflows/cache-preview.yaml
pull_request_review:
types: [submitted]

jobs:
image-build:
runs-on: ubicloud-standard-2
if: github.event.review.state == 'approved'
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
steps:
- uses: actions/checkout@v4

- name: Check for path changes
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
cache:
- 'services/cache/**'
- '.github/workflows/cache-preview.yaml'
- name: Login to Github Packages
if: steps.changes.outputs.cache == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
if: steps.changes.outputs.cache == 'true'
id: qemu
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: 🏗 Setup repo
uses: actions/checkout@v4

- name: Set up Docker Context for Buildx
if: steps.changes.outputs.cache == 'true'
run: docker context create builders

- name: Set up Docker Buildx
if: steps.changes.outputs.cache == 'true'
uses: docker/setup-buildx-action@v3
with:
version: latest
endpoint: builders

- name: Docker meta
if: steps.changes.outputs.cache == 'true'
id: cache
uses: docker/metadata-action@v5
with:
Expand All @@ -51,10 +66,11 @@ jobs:
type=raw,value=latest
- name: Build
if: steps.changes.outputs.cache == 'true'
uses: docker/build-push-action@v6
with:
context: services/cache
platforms: linux/arm64,linux/amd64
push: false
tags: ${{ steps.cache.outputs.tags }}
labels: ${{ steps.cache.outputs.labels }}
labels: ${{ steps.cache.outputs.labels }}
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
name: core-unit-test
name: Core Service Preview

on:
pull_request_review:
types: [submitted]
pull_request:
types: [opened, synchronize]
branches:
- main
paths:
- '*.go'
- 'go.mod'
- 'go.sum'
- .github/workflows/core-pull.yaml
- .github/workflows/core-preview.yaml
pull_request_review:
types: [submitted]

jobs:
core-unit-test:
if: github.event.review.state == 'approved'
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
name: Core unit tests
runs-on: ubicloud-standard-2
strategy:
Expand All @@ -22,66 +24,96 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Check for path changes
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
core:
- '*.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/core-preview.yaml'
- name: Copy and rename config file
if: steps.changes.outputs.core == 'true'
run: cp config_example.yaml config.yaml

- name: Setup Go ${{ matrix.go-version }}
if: steps.changes.outputs.core == 'true'
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Install dependencies
if: steps.changes.outputs.core == 'true'
run: go get -v

- name: Run unit tests
if: steps.changes.outputs.core == 'true'
run: ENV=test go test ./...


core-docker-build:
if: github.event.review.state == 'approved'
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
runs-on: ubicloud-standard-2
steps:
- uses: actions/checkout@v4

- name: Check for path changes
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
core:
- '*.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/core-preview.yaml'
- name: Login to Github Packages
if: steps.changes.outputs.core == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
if: steps.changes.outputs.core == 'true'
id: qemu
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: 🏗 Setup repo
uses: actions/checkout@v4

- name: Set up Docker Context for Buildx
if: steps.changes.outputs.core == 'true'
run: docker context create builders

- name: Set up Docker Buildx
if: steps.changes.outputs.core == 'true'
uses: docker/setup-buildx-action@v3
with:
version: latest
endpoint: builders

- name: Docker meta
id: openshield
if: steps.changes.outputs.core == 'true'
id: cache
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/openshieldai/openshield/openshield
ghcr.io/openshieldai/openshield/cache
tags: |
type=sha
type=raw,value=latest
- name: Build
if: steps.changes.outputs.core == 'true'
uses: docker/build-push-action@v6
with:
context: .
context: services/cache
platforms: linux/arm64,linux/amd64
push: false
tags: ${{ steps.api.outputs.tags }}
labels: ${{ steps.api.outputs.labels }}
tags: ${{ steps.cache.outputs.tags }}
labels: ${{ steps.cache.outputs.labels }}
3 changes: 2 additions & 1 deletion .github/workflows/discord-notifications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ on:

jobs:
github-releases-to-discord:
name: Github Releases To Discord
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Github Releases To Discord
uses: SethCohen/github-releases-to-discord@v1
uses: SethCohen/github-releases-to-discord@v1.16.2
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}
color: "2105893"
Expand Down
166 changes: 166 additions & 0 deletions .github/workflows/rule-server-preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: Rule Server Service Preview

on:
pull_request:
types: [opened, synchronize]
branches:
- main
paths:
- services/rule/**
- .github/workflows/rule-server-preview.yaml
pull_request_review:
types: [submitted]

jobs:
rule-server-unit-test-x86:
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
name: Rule server unit tests
runs-on: ubicloud-standard-2
strategy:
matrix:
python-version: ["3.11"]
poetry-version: ["1.8.3"]

steps:
- uses: actions/checkout@v4

- name: Check for path changes
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
rule:
- 'services/rule/**'
- '.github/workflows/rule-server-preview.yaml'
- name: Set up Python ${{ matrix.python-version }}
if: steps.changes.outputs.rule == 'true'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Run poetry action
if: steps.changes.outputs.rule == 'true'
uses: abatilo/actions-poetry@v3
with:
poetry-version: ${{ matrix.poetry-version }}

- name: Install dependencies
if: steps.changes.outputs.rule == 'true'
run: |
cd services/rule
poetry install
- name: Run unit tests
if: steps.changes.outputs.rule == 'true'
run: |
cd services/rule/src/tests
poetry run python -m unittest test_api.py
rule-server-unit-test-arm:
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
name: Rule server unit tests
runs-on: ubicloud-standard-2-arm
strategy:
matrix:
python-version: ["3.11"]
poetry-version: ["1.8.3"]

steps:
- uses: actions/checkout@v4

- name: Check for path changes
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
rule:
- 'services/rule/**'
- '.github/workflows/rule-server-preview.yaml'
- name: Set up Python ${{ matrix.python-version }}
if: steps.changes.outputs.rule == 'true'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Run poetry action
if: steps.changes.outputs.rule == 'true'
uses: abatilo/actions-poetry@v3
with:
poetry-version: ${{ matrix.poetry-version }}

- name: Install dependencies
if: steps.changes.outputs.rule == 'true'
run: |
cd services/rule
poetry install
- name: Run unit tests
if: steps.changes.outputs.rule == 'true'
run: |
cd services/rule/src/tests
poetry run python -m unittest test_api.py
rule-service-docker-build:
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
runs-on: ubicloud-standard-2
steps:
- uses: actions/checkout@v4

- name: Check for path changes
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
rule:
- 'services/rule/**'
- '.github/workflows/rule-server-preview.yaml'
- name: Login to Github Packages
if: steps.changes.outputs.rule == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
if: steps.changes.outputs.rule == 'true'
id: qemu
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: Set up Docker Context for Buildx
if: steps.changes.outputs.rule == 'true'
run: docker context create builders

- name: Set up Docker Buildx
if: steps.changes.outputs.rule == 'true'
uses: docker/setup-buildx-action@v3
with:
version: latest
endpoint: builders

- name: Docker meta
if: steps.changes.outputs.rule == 'true'
id: rule-service
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/openshieldai/openshield/rule
tags: |
type=sha
type=raw,value=latest
- name: Build
if: steps.changes.outputs.rule == 'true'
uses: docker/build-push-action@v6
with:
context: services/rule
platforms: linux/arm64,linux/amd64
push: false
tags: ${{ steps.rule-service.outputs.tags }}
labels: ${{ steps.rule-service.outputs.labels }}
Loading

0 comments on commit 25e675b

Please sign in to comment.