Skip to content

Commit

Permalink
feat: add new model
Browse files Browse the repository at this point in the history
  • Loading branch information
MitaWinata committed Jan 8, 2024
1 parent fc2c6d8 commit 1c8fc91
Show file tree
Hide file tree
Showing 28 changed files with 623 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/config/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
// Ignore defaults from https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/is-ignored/src/defaults.ts#L20-L26
// to have warnings for fixup! etc.
defaultIgnores: false,
};
7 changes: 7 additions & 0 deletions .github/config/markdown-lint.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"MD013": false,
"MD024": {
"siblings_only": true
},
"MD012": false
}
31 changes: 31 additions & 0 deletions .github/config/yaml-lint-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---

yaml-files:
- '*.yaml'
- '*.yml'

ignore:
- '**/.deploy/charts/*/templates'

rules:
braces: enable
brackets: enable
colons: enable
commas: enable
comments: enable
comments-indentation: enable
document-end: disable
document-start: disable
empty-lines: enable
empty-values: disable
hyphens: enable
indentation: enable
key-duplicates: enable
key-ordering: disable
line-length: disable
new-line-at-end-of-file: enable
new-lines: disable
octal-values: enable
quoted-strings: disable
trailing-spaces: enable
truthy: disable
6 changes: 6 additions & 0 deletions .github/scripts/install-agent-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Installs tools needed for the agent

sudo npm install -g markdownlint-cli
sudo pip install yamllint
23 changes: 23 additions & 0 deletions .github/workflows/a/deploy_a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: FullWorkflow-Deploy-a

on:
push:
branches:
- main
paths:
- 'model/a/**'

jobs:
style:
uses: ./../.github/workflows/style.yml
tests_a:
uses: ./../.github/workflows/tests.yml
with:
src_path: "model/a"
python_style_a:
uses: ./../.github/workflows/python_style.yml
with:
src_path: "model/a"
release:
needs: [style, tests_a, python_style_a]
uses: ./../.github/workflows/release.yaml
24 changes: 24 additions & 0 deletions .github/workflows/a/pr_a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: FullWorkflow-PR-a

on:
pull_request:
branches:
- main
paths:
- 'model/a/**'

jobs:
style:
uses: ./../.github/workflows/style.yml
tests_a:
uses: ./../.github/workflows/tests.yml
with:
src_path: "model/a"
python_style_a:
uses: ./../.github/workflows/python_style.yml
with:
src_path: "model/a"
docker_a:
uses: ./../.github/workflows/docker.yml
with:
build_context: "a"
23 changes: 23 additions & 0 deletions .github/workflows/b/deploy_b.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: FullWorkflow-Deploy-b

on:
push:
branches:
- main
paths:
- 'model/b/**'

jobs:
style:
uses: ./../.github/workflows/style.yml
tests_b:
uses: ./../.github/workflows/tests.yml
with:
src_path: "model/b"
python_style_b:
uses: ./../.github/workflows/python_style.yml
with:
src_path: "model/b"
release:
needs: [style, tests_b, python_style_b]
uses: ./../.github/workflows/release.yaml
24 changes: 24 additions & 0 deletions .github/workflows/b/pr_b.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: FullWorkflow-PR-b

on:
pull_request:
branches:
- main
paths:
- 'model/b/**'

jobs:
style:
uses: ./../.github/workflows/style.yml
tests_b:
uses: ./../.github/workflows/tests.yml
with:
src_path: "model/b"
python_style_b:
uses: ./../.github/workflows/python_style.yml
with:
src_path: "model/b"
docker_b:
uses: ./../.github/workflows/docker.yml
with:
build_context: "b"
74 changes: 74 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: BuildPublishImage

on:
workflow_call:
inputs:
build_context:
description: 'build_context'
required: false
type: string
image_tag:
description: 'Image tag'
required: false
type: string

permissions:
id-token: write
contents: read
packages: write

env:
ACR_NAME: "monorepopwin.azurecr.io"

jobs:
BuildDocker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 'Az CLI login'
uses: azure/login@v1
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
allow-no-subscriptions: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.ACR_NAME }}/${{ inputs.build_context }}
tags: |
type=edge,branch=main
type=ref,event=tag
type=ref,event=pr
type=raw, ${{ inputs.image_tag}}
- name: Log into azurecr registry
run: |
TOKEN=$(az acr login --name ${{ env.ACR_NAME }} --expose-token --output tsv --query accessToken)
echo "::add-mask::${TOKEN}"
docker login ${{ env.ACR_NAME }} --username 00000000-0000-0000-0000-000000000000 --password-stdin <<< $TOKEN
shell: bash

- name: Build, push if not PR
uses: docker/build-push-action@v5
with:
context: model/${{ inputs.build_context }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}

- name: Azure Logout
if: always()
run: |
az logout
az cache purge
az account clear
shell: bash
50 changes: 50 additions & 0 deletions .github/workflows/python_style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CheckStyle

on:
workflow_call:
inputs:
src_path:
description: 'src_path'
required: false
type: string

permissions:
contents: read

jobs:
CheckCodeStyle:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Poetry
uses: snok/install-poetry@v1

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{matrix.version}}
cache: 'poetry'

- name: Install dependencies
run: |
cd ${{ inputs.src_path }}
poetry install --only dev
shell: bash

- name: Run isort
run: |
cd ${{ inputs.src_path }}
poetry run isort --check --profile black .
shell: bash

- name: Run black
run: |
cd ${{ inputs.src_path }}
poetry run black --check --diff .
shell: bash
67 changes: 67 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release Workflow

on:
workflow_call:
outputs:
a-release_created:
value: ${{ jobs.release_job.outputs.a-release_created }}
a-tag_name:
value: ${{ jobs.release_job.outputs.a-tag_name }}
b-release_created:
value: ${{ jobs.release_job.outputs.b-release_created }}
b-tag_name:
value: ${{ jobs.release_job.outputs.b-tag_name }}

permissions:
contents: write
pull-requests: write
id-token: write
packages: write

concurrency:
group: release

jobs:
release_job:
runs-on: ubuntu-latest
outputs:
a-release_created: ${{ steps.create_output.outputs.a-release_created }}
a-tag_name: ${{ steps.create_output.outputs.a-tag_name }}
b-release_created: ${{ steps.create_output.outputs.b-release_created }}
b-tag_name: ${{ steps.create_output.outputs.b-tag_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Release with release-please
uses: google-github-actions/release-please-action@v3
id: release
with:
command: manifest
monorepo-tags: true
pull-request-header: ":robot: I have created a release"
- name: "Generate release-please output"
id: create_output
shell: bash
run: |
echo "a-release_created=$(echo ${{ steps.release.outputs['model/a--release_created'] }})" >> "$GITHUB_OUTPUT"
echo "a-tag_name=$(echo ${{ steps.release.outputs['model/a--tag_name'] }})" >> "$GITHUB_OUTPUT"
echo "b-release_created=$(echo ${{ steps.release.outputs['model/b--release_created'] }})" >> "$GITHUB_OUTPUT"
echo "b-tag_name=$(echo ${{ steps.release.outputs['model/b--tag_name'] }})" >> "$GITHUB_OUTPUT"
build_publish_a_image:
name: Build Publish a Image
uses: ./.github/workflows/docker.yml
needs: release_job
if: needs.release_job.outputs.a-release_created == 'true'
with:
image_tag: ${{ needs.release_job.outputs.a-tag_name }}
build_context: "a"
build_publish_b_image:
name: Build Publish b Image
uses: ./.github/workflows/docker.yml
needs: release_job
if: needs.release_job.outputs.b-release_created == 'true'
with:
image_tag: ${{ needs.release_job.outputs.b-tag_name }}
build_context: "b"
46 changes: 46 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CheckStyle

on:
pull_request:
branches:
- main
workflow_call:

permissions:
contents: read

jobs:
CheckCommitStyle:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install commitlint dependencies
run: |
npm i --global "@commitlint/config-conventional@17" "@commitlint/cli@17"
shell: bash
- name: Conventional Commit Linting
run: |
# Linting commits from source branch tip to target branch tip
commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose --config ./.github/config/commitlint.config.js
shell: bash
CheckYamlMarkdownStyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install tools
run: |
./.github/scripts/install-agent-tools.sh
shell: bash
- name: Lint Markdown
run: |
markdownlint . -c ./.github/config/markdown-lint.config
shell: bash
- name: Lint YAML
run: |
yamllint -c ./.github/config/yaml-lint-config.yml --strict .
shell: bash
Loading

0 comments on commit 1c8fc91

Please sign in to comment.