File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Lint and test workflow
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+ workflow_dispatch :
8+
9+ jobs :
10+ SanitizeBranchName :
11+ runs-on : ubuntu-latest
12+ outputs :
13+ sanitized_ref : ${{ steps.sanitize.outputs.sanitized_ref }}
14+ steps :
15+ - name : Sanitize Branch Name
16+ id : sanitize
17+ run : |
18+ SANITIZED_REF=$(echo "${GITHUB_HEAD_REF}" | tr '[:upper:]' '[:lower:]' | tr -c 'a-z0-9' '-')
19+ SANITIZED_REF=${SANITIZED_REF#-}
20+ SANITIZED_REF=${SANITIZED_REF%-}
21+ SANITIZED_REF=${SANITIZED_REF:0:63}
22+ if [[ -z "$SANITIZED_REF" || "$SANITIZED_REF" =~ ^-+$ ]]; then
23+ SANITIZED_REF="tmp-branch"
24+ fi
25+ echo "::set-output name=sanitized_ref::${SANITIZED_REF}"
26+ shell : bash
27+ env :
28+ GITHUB_HEAD_REF : ${{ github.head_ref }}
29+
30+ BuildAndLint :
31+ name : Build and Lint
32+ runs-on : ubuntu-latest
33+ needs : [SanitizeBranchName]
34+ strategy :
35+ fail-fast : true
36+ matrix :
37+ service : [ "admin-backend", "document-extractor", "rag-backend"]
38+ steps :
39+ - name : Checkout code
40+ uses : actions/checkout@v4
41+ with :
42+ token : ${{ secrets.GITHUB_TOKEN }}
43+ repository : stackitcloud/rag-template
44+ submodules : ' true'
45+ - name : Set Docker Image Name
46+ run : |
47+ echo "IMAGE_NAME=${{ matrix.service }}:${{ needs.SanitizeBranchName.outputs.sanitized_ref }}-${{ github.run_number }}" >> $GITHUB_ENV
48+ shell : bash
49+
50+ - name : Build lint image
51+ run : |
52+ docker build -t $IMAGE_NAME --build-arg dev=1 --build-arg TAG=debug -f ${{ matrix.service }}/Dockerfile .
53+
54+ - name : Generate lint report
55+ run : |
56+ docker run --rm --entrypoint make "$IMAGE_NAME" lint
57+
58+ - name : Run tests
59+ run : |
60+ docker run --rm --entrypoint make "$IMAGE_NAME" test
You can’t perform that action at this time.
0 commit comments