This repository has been archived by the owner on Aug 30, 2024. It is now read-only.
mha enhance #632
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
name: Format Scan | |
on: | |
pull_request: | |
branches: [main] | |
paths: | |
- neural_speed/** | |
- bestla/** | |
- scripts/** | |
- clang-format.py | |
- setup.py | |
- .github/workflows/format_scan.yml | |
- .github/workflows/scripts/formatScan/** | |
- "!bestla/*.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: "codeScan" | |
CONTAINER_NAME: "codeScan" | |
jobs: | |
format-scan: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
job_name: [ | |
"pylint", | |
"bandit", | |
"clangformat", | |
"cloc", | |
"clangtidy", | |
# "pydocstyle", | |
#"pyspelling", | |
] | |
fail-fast: false | |
steps: | |
- name: Docker Clean Up | |
run: | | |
docker ps -a | |
if [[ $(docker ps -a | grep -i '${{ env.CONTAINER_NAME }}'$) ]]; then | |
docker start ${{ env.CONTAINER_NAME }} | |
echo "remove left files through container ..." | |
docker exec ${{ env.CONTAINER_NAME }} bash -c "ls -a /neural-speed && rm -fr /neural-speed/* && rm -fr /neural-speed/.* || true" | |
fi | |
- name: Checkout out Repo | |
uses: actions/checkout@v3 | |
- 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 }}:/neural-speed \ | |
${{ env.REPO_NAME }}:${{ env.REPO_TAG }} | |
- name: Env build | |
run: | | |
docker exec ${{ env.CONTAINER_NAME }} \ | |
bash /neural-speed/.github/workflows/scripts/prepare_env.sh | |
- name: Code scan check | |
run: | | |
docker exec ${{ env.CONTAINER_NAME }} \ | |
bash -c "bash /neural-speed/.github/workflows/scripts/formatScan/${{ matrix.job_name }}.sh" | |
- name: Publish pipeline artifact | |
if: ${{ !cancelled() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.job_name }} | |
path: ${{ github.workspace }}/.github/workflows/scripts/formatScan/${{ matrix.job_name }}.* |