Skip to content

Commit

Permalink
Merge branch 'main' into feature/PTFE-700-add-build-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Abubakarr99 authored Aug 3, 2023
2 parents 557399d + 7fc7b49 commit fb1f5a8
Show file tree
Hide file tree
Showing 43 changed files with 973 additions and 74 deletions.
11 changes: 9 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "Python 3",
"image": "mcr.microsoft.com/devcontainers/base:1-jammy",
"remoteEnv": {
"GITHUB_BASE_URL": "http://localhost:4010"
},
"features": {
"ghcr.io/devcontainers/features/python": {
"version": "3.11",
Expand All @@ -23,11 +26,15 @@
"extensions": [
"GitHub.copilot",
"bierner.markdown-mermaid",
"tamasfe.even-better-toml"
"tamasfe.even-better-toml",
"github.vscode-github-actions"
],
"settings": {
"python.analysis.typeCheckingMode": "basic",
"python.defaultInterpreterPath": ".venv/bin/python"
"python.defaultInterpreterPath": ".venv/bin/python",
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
}
},
Expand Down
33 changes: 33 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
commit-message:
prefix: "github-actions"
include: "scope"
labels:
- "github-actions"
- "dependencies"
- package-ecosystem: docker
directory: "/"
schedule:
interval: daily
commit-message:
prefix: "docker"
include: "scope"
labels:
- "docker"
- "dependencies"
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
commit-message:
prefix: "pip"
include: "scope"
labels:
- "pip"
- "dependencies"
24 changes: 24 additions & 0 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: codeQL

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch: {}

jobs:
analyze:
name: Static analysis with CodeQL
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: python

- name: Build and analyze
uses: github/codeql-action/analyze@v2
15 changes: 15 additions & 0 deletions .github/workflows/dependency-review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: dependency review

on:
pull_request:
branches: [main]

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Dependency Review
uses: actions/dependency-review-action@v3
36 changes: 36 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: release

on:
workflow_dispatch:
inputs:
tag:
description: Tag to be released
required: true
prerelease:
description: Define the release as pre-release
required: false
default: false
type: boolean

jobs:
docker:
uses: scality/workflows/.github/workflows/docker-build.yaml@v1
with:
name: runner-manager
namespace: scality
tag: ${{ inputs.tag }}

release:
runs-on: ubuntu-latest
needs: docker
steps:
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target_commitish: ${{ github.sha }}
tag_name: ${{ inputs.tag }}
name: Release ${{ inputs.tag }}
prerelease: ${{ inputs.prerelease }}
generate_release_notes: true
46 changes: 46 additions & 0 deletions .github/workflows/test-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: test-deployment


on: pull_request

permissions:
contents: read

jobs:
docker-build:
permissions:
contents: read
packages: write
uses: scality/workflows/.github/workflows/docker-build.yaml@v1
with:
name: runner-manager
namespace: scality
test-deployment:
needs: docker-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: helm/kind-action@v1
- name: Edit the runner-manager image
working-directory: tests
run: |
cat <<EOF > kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: ghcr.io/scality/runner-manager
newTag: ${{ github.sha }}
resources:
- ../manifests
EOF
- name: Deploy runner-manager
run: kustomize build tests/ | kubectl apply -f -
- name: Check if deployment is ready
run: |
kubectl rollout status statefulset redis --timeout=90s
kubectl rollout status deployment runner-manager --timeout=120s
kubectl rollout status deployment runner-manager-worker --timeout=120s
- name: get all resources
if: failure()
run: kubectl get all
24 changes: 17 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,29 @@ permissions:
contents: read

jobs:
unit:
test:
name: ${{ matrix.test }}
runs-on: ubuntu-latest
services:
redis:
image: redis/redis-stack
ports:
- 6379:6379
strategy:
matrix:
test: [unit, api]

env:
REDIS_OM_URL: redis://localhost:6379
GITHUB_BASE_URL: http://localhost:4010

steps:
- uses: actions/checkout@v3
- name: Boot compose services
run: docker compose --profile tests up --build --detach
- run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: 3.11
cache: poetry
- run: poetry install
- run: poetry run pytest tests/unit
- name: Run tests
run: poetry run pytest tests/${{ matrix.test }}
- name: Dump logs
run: docker compose --profile tests logs
if: always()
1 change: 0 additions & 1 deletion .github/workflows/trunk-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Trunk Check
uses: trunk-io/trunk-action@v1
8 changes: 1 addition & 7 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@ lint:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
disabled:
- checkov
- bandit
- osv-scanner
- trivy
- terrascan
triggers:
- linters: [checkov]
paths:
- .github/workflows
targets:
- .github/workflows
runtimes:
enabled:
- [email protected]
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ version: "2"

services:
redis:
profiles:
- main
- develop
- tests
image: redis/redis-stack
ports:
- 6379:6379
- 8001:8001
volumes:
- redis_data:/data
runner-manager:
profiles:
- main
- develop
build: .
ports:
- 8000:8000
Expand All @@ -25,6 +32,9 @@ services:
- action: rebuild
path: docker-compose.yaml
worker:
profiles:
- main
- develop
build: .
command: rq worker -c runner_manager.jobs.settings
volumes:
Expand All @@ -34,6 +44,7 @@ services:
github-mock:
profiles:
- develop
- tests
build: tests/images/github-mock
ports:
- 4010:4010
Expand Down
5 changes: 3 additions & 2 deletions docs/development/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The global configuration will contain the following information:
- A name for the runner manager. (default: runner-manager)
It will be used as a metadata or prefix which will allow the runner to identify
the owner of each resources, avoiding conflicts with other runner managers or users.
- The default GitHub organization in which the runner and groups will be created.
(Required)
- The GitHub Authentication parameters. (Required)
- For GitHub Application: The GitHub Application ID, Installation ID and Private Key. (Required)
- For GitHub Personal Access Token: The GitHub Personal Access Token. (Required)
Expand All @@ -32,7 +34,7 @@ settings file.
The following information will be configured for each runner group:

- Name of the group. (Required)
- Name of the GitHub Organization in which the runner and group will be created. (Required)
- Name of the GitHub Organization in which the runner and group will be created. (optional)
- Name of the GitHub Repository in which the runner and group will be created. (Optional)
- Repository access:
- A list of selected repositories. (Default: All repositories)
Expand All @@ -44,7 +46,6 @@ The following information will be configured for each runner group:
octo-org/octo-repo/.github/workflows/deploy.yml@d6dc6c96df4f32fa27b039f2084f576ed2c5c2a5,
monalisa/octo-test/.github/workflows/test.yml@main
```
- The name of the workflow that will be used to run the jobs. (Optional)
- The maximum number of runners that can run simultaneously. (Default: 20)
- The minimum number of runners that must be available. (Default: 0)
- The runner labels that will be attached to the runners of the group. (Required)
Expand Down
7 changes: 7 additions & 0 deletions manifests/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- runner-manager
- redis
17 changes: 17 additions & 0 deletions manifests/base/redis/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization


commonLabels:
app.kubernetes.io/instance: redis
app.kubernetes.io/name: redis
app.kubernetes.io/component: database
app.kubernetes.io/part-of: runner-manager
images:
- name: redis
newName: redis/redis-stack
newTag: 6.2.6-v9
resources:
- statefulset.yaml
- service.yaml
11 changes: 11 additions & 0 deletions manifests/base/redis/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: v1
kind: Service
metadata:
name: redis
spec:
clusterIP: None
ports:
- protocol: TCP
port: 6379
targetPort: 6379
Loading

0 comments on commit fb1f5a8

Please sign in to comment.