forked from inno-devops-labs/S24-core-course-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Go application | ||
|
||
on: | ||
push: | ||
paths: | ||
- .github/workflows/** | ||
- app_go/** | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
lint-test-snyk: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
go-version: ["1.21", "1.22"] | ||
|
||
defaults: | ||
run: | ||
working-directory: ./app_go | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
#cache-dependency-path: app_go/go.sum | ||
- name: Build | ||
run: go build | ||
- name: Lint with `go vet` | ||
run: go vet | ||
- name: Test with `go test` | ||
run: | | ||
go test | ||
- name: Check for vulnerabilities with Snyk | ||
uses: snyk/actions/golang@master | ||
with: | ||
args: app_go/ | ||
env: | ||
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
|
||
|
||
docker-build-push: | ||
needs: [ lint-test-snyk ] | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Cache Docker images | ||
uses: ScribeMD/[email protected] | ||
with: | ||
key: docker-app_go | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: kolay0ne | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build and push docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
context: "{{defaultContext}}:app_go/" | ||
tags: kolay0ne/app_go:${{ github.ref_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# CI for `app_python` | ||
|
||
## Best practices | ||
|
||
- Runs on push only if files in related directories have changed. | ||
|
||
- Uses matrix strategy: runs tests with different python versions, | ||
can be extended further, e.g., to use different operating systems. | ||
|
||
- In the lint&test job, dependencies are cached and reused. Cache is | ||
updated when newer versions of dependent libraries are released. | ||
|
||
- In the docker build&push job, docker layers are cached and reused. | ||
Cache is updated when any of the layers change. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters