Skip to content

Commit

Permalink
CORE-2169 support Python applications (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
baksetercx authored Dec 21, 2024
1 parent 42cb2a9 commit 98b33c4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
43 changes: 28 additions & 15 deletions .github/workflows/test-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
matrix-trivy: ${{ steps.set-matrices.outputs.matrix-trivy }}
all-changed-files: ${{ steps.changed-files.outputs.all_changed_files }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set matrices
id: set-matrices
run: |
Expand All @@ -43,7 +46,7 @@ jobs:
cat << EOF
{
"runner": ["$RUNNER"],
"language": ["csharp","go"]
"language": ["csharp","go","python"]
}
EOF
echo EOF
Expand All @@ -58,7 +61,8 @@ jobs:
"project-file": [
"applications/demo-api/demo-api/core-demo-api.csproj",
"applications/demo-api-go/go.mod",
"applications/demo-api-go/Dockerfile"
"applications/demo-api-go/Dockerfile",
"applications/demo-api-python/uv.lock"
],
"registry": ["","ghcr.io/3lvia"],
"include": [
Expand All @@ -68,6 +72,10 @@ jobs:
{
"application-name": "${{ env.APPLICATION_BASE_NAME }}",
"project-file": "applications/demo-api/demo-api/core-demo-api.csproj"
},
{
"application-name": "${{ env.APPLICATION_BASE_NAME }}-python",
"project-file": "applications/demo-api-python/uv.lock"
}
]
}
Expand All @@ -83,7 +91,8 @@ jobs:
"runner": ["$RUNNER","ubuntu-latest"],
"application-name": [
"${{ env.APPLICATION_BASE_NAME }}",
"${{ env.APPLICATION_BASE_NAME }}-go"
"${{ env.APPLICATION_BASE_NAME }}-go",
"${{ env.APPLICATION_BASE_NAME }}-python"
],
"runtime-cloud-provider": ["AKS","GKE"],
"include": [
Expand All @@ -93,7 +102,11 @@ jobs:
{
"application-name": "${{ env.APPLICATION_BASE_NAME }}-go",
"helm-values-file": ".github/deploy/values-demo-api-go.yml"
}
},
{
"application-name": "${{ env.APPLICATION_BASE_NAME }}-go",
"helm-values-file": ".github/deploy/values-demo-api-python.yml"
},
]
}
EOF
Expand Down Expand Up @@ -134,7 +147,7 @@ jobs:
actions: read
contents: read
security-events: write
if: ${{ contains(needs.pepare-jobs.outputs.all-changed-files, 'analyze/action.yml') }}
if: ${{ github.event_name != 'pull_request' || contains(needs.prepare-jobs.outputs.all-changed-files, 'analyze/action.yml') }}
steps:
- name: Checkout this repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -174,7 +187,7 @@ jobs:
checks: write
issues: read
pull-requests: write
if: ${{ contains(needs.pepare-jobs.outputs.all-changed-files, 'unittest/action.yml') }}
if: ${{ github.event_name != 'pull_request' || contains(needs.prepare-jobs.outputs.all-changed-files, 'unittest/action.yml') }}
steps:
- name: Checkout this repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -207,7 +220,7 @@ jobs:
matrix: ${{ fromJson(needs.prepare-jobs.outputs.matrix-build) }}
concurrency:
group: |
${{ github.workflow }}-${{ github.event_name }}-${{ github.job }}-${{ matrix.runner }}-${{ matrix.application-name }}-${{ matrix.project-file }}-${{ matrix.registry }}
${{ github.workflow }}-${{ github.event_name }}-${{ matrix.runner }}-${{ matrix.application-name }}-${{ matrix.project-file }}-${{ matrix.registry }}
cancel-in-progress: true
runs-on: ${{ matrix.runner }}
permissions:
Expand All @@ -218,7 +231,7 @@ jobs:
pull-requests: write
security-events: write
environment: build
if: ${{ contains(needs.pepare-jobs.outputs.all-changed-files, 'build/action.yml') }}
if: ${{ github.event_name != 'pull_request' || contains(needs.prepare-jobs.outputs.all-changed-files, 'build/action.yml') }}
steps:
- name: Checkout this repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -321,7 +334,7 @@ jobs:
id-token: write
environment: dev
# Changes in build might affect deploy, so we test deploy as well if build has changed.
if: ${{ contains(needs.prepare-jobs.outputs.all-changed-files, 'build/action.yml') || contains(needs.prepare-jobs.outputs.all-changed-files, 'deploy/action.yml') }}
if: ${{ github.event_name != 'pull_request' || contains(needs.prepare-jobs.outputs.all-changed-files, 'build/action.yml') || contains(needs.prepare-jobs.outputs.all-changed-files, 'deploy/action.yml') }}
steps:
- name: Checkout this repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -369,7 +382,7 @@ jobs:
issues: read
pull-requests: write
id-token: write
if: ${{ contains(needs.prepare-jobs.outputs.all-changed-files, 'integrationtest/action.yml') }}
if: ${{ github.event_name != 'pull_request' || contains(needs.prepare-jobs.outputs.all-changed-files, 'integrationtest/action.yml') }}
steps:
- name: Checkout this repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -411,7 +424,7 @@ jobs:
actions: read
contents: read
security-events: write
if: ${{ contains(needs.prepare-jobs.outputs.all-changed-files, 'trivy-iac-scan/action.yml') }}
if: ${{ github.event_name != 'pull_request' || contains(needs.prepare-jobs.outputs.all-changed-files, 'trivy-iac-scan/action.yml') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -429,7 +442,7 @@ jobs:
group: '${{ github.workflow }}-${{ github.event_name }}-${{ matrix.runner }}-terraform-format'
cancel-in-progress: true
runs-on: ${{ matrix.runner }}
if: ${{ contains(needs.prepare-jobs.outputs.all-changed-files, 'terraform-format/action.yml') }}
if: ${{ github.event_name != 'pull_request' || contains(needs.prepare-jobs.outputs.all-changed-files, 'terraform-format/action.yml') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -450,7 +463,7 @@ jobs:
permissions:
contents: read
id-token: write
if: ${{ contains(needs.prepare-jobs.outputs.all-changed-files, 'slack-message/action.yml') }}
if: ${{ github.event_name != 'pull_request' || contains(needs.prepare-jobs.outputs.all-changed-files, 'slack-message/action.yml') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -471,7 +484,7 @@ jobs:
group: '${{ github.workflow }}-${{ github.event_name }}-${{ matrix.runner }}-slack-message-token'
cancel-in-progress: true
runs-on: ${{ matrix.runner }}
if: ${{ contains(needs.prepare-jobs.outputs.all-changed-files, 'slack-message/action.yml') }}
if: ${{ github.event_name != 'pull_request' || contains(needs.prepare-jobs.outputs.all-changed-files, 'slack-message/action.yml') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -494,7 +507,7 @@ jobs:
permissions:
contents: read
id-token: write
if: ${{ contains(needs.prepare-jobs.outputs.all-changed-files, 'vault/action.yml') }}
if: ${{ github.event_name != 'pull_request' || contains(needs.prepare-jobs.outputs.all-changed-files, 'vault/action.yml') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ inputs:
Please use `project-file` instead, which is a drop-in replacement. `dockerfile` will be removed in the future.
project-file:
description: |
Path to a `.csproj`-file for .NET, a `go.mod` file for Go or a Dockerfile for any other project.
E.g. `applications/my-app/my-app.csproj`, `pkg/my-app/go.mod` or `src/Dockerfile`.
Path to a `.csproj`-file for .NET, a `go.mod` file for Go, a `uv.lock` file for Python or a Dockerfile for any other project.
E.g. `applications/my-app/my-app.csproj`, `pkg/my-app/go.mod`, `uv.lock` or `src/Dockerfile`.
If you require files outside the directory of the `project-file` to build your application, you will need to set `docker-build-context`.
required: false
go-main-package-dir:
Expand Down Expand Up @@ -161,7 +161,7 @@ runs:
- name: Install 3lv CLI
uses: 3lvia/cli/setup@trunk
with:
version: '0.23.1' # TODO: remove this (which will get latest version) when 3lv CLI is stable
version: '0.24.0' # TODO: remove this (which will get latest version) when 3lv CLI is stable

- name: Handle deprecated inputs
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ runs:
- name: Install 3lv CLI
uses: 3lvia/cli/setup@trunk
with:
version: '0.23.1' # TODO: remove this (which will get latest version) when 3lv CLI is stable
version: '0.24.0' # TODO: remove this (which will get latest version) when 3lv CLI is stable

- name: Deploy
shell: bash
Expand Down

0 comments on commit 98b33c4

Please sign in to comment.