add ut #7
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# Copyright (c) 2022 Intel Corporation | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: Code Scan | |
on: | |
pull_request: | |
branches: [main] | |
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped | |
paths-ignore: | |
- "**.md" | |
workflow_dispatch: | |
# If there is a new commit, the previous jobs will be canceled | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
DOCKER_CONFIG_NAME: "commonDockerConfig" | |
REPO_NAME: "code-scan" | |
REPO_TAG: "1.0" | |
DOCKER_FILE_NAME: "code-scan" | |
CONTAINER_NAME: "code-scan" | |
jobs: | |
code-scan: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
job_name: ["bandit"] | |
fail-fast: false | |
steps: | |
- name: Checkout out Repo | |
uses: actions/checkout@v4 | |
- name: Docker Build | |
run: | | |
docker build -f ${{ github.workspace }}/.github/workflows/docker/${{ env.DOCKER_FILE_NAME }}.dockerfile -t ${{ env.REPO_NAME }}:${{ env.REPO_TAG }} . | |
- name: Docker Run | |
run: | | |
if [[ $(docker ps -a | grep -i '${{ env.CONTAINER_NAME }}'$) ]]; then | |
docker stop ${{ env.CONTAINER_NAME }} | |
docker rm -vf ${{ env.CONTAINER_NAME }} || true | |
fi | |
docker run -dit --memory="4g" --memory-reservation="1g" --disable-content-trust --privileged --name=${{ env.CONTAINER_NAME }} --shm-size="1g" \ | |
-v ${{ github.workspace }}:/GenAIEval \ | |
${{ env.REPO_NAME }}:${{ env.REPO_TAG }} | |
- name: Code scan check | |
run: | | |
docker exec ${{ env.CONTAINER_NAME }} \ | |
bash -c "bash /GenAIEval/.github/workflows/scripts/codeScan/${{ matrix.job_name }}.sh" | |
- name: Publish pipeline artifact | |
if: ${{ !cancelled() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.job_name }} | |
path: ${{ github.workspace }}/.github/workflows/scripts/codeScan/${{ matrix.job_name }}.* |