[MS-665] Rename Claude2 Connector to Anthropic Token #50
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
# Pre-build Checks (for moonshot-data) | |
# 1. Unit tests with code coverage (pytest) | |
# 2. Code quality analysis (flake8) | |
# 3. Dependency analysis (vulnerabilities) | |
# 4. Dependency analysis (undesirable licenses) | |
# 5. Deploy reports generated from the above to GitHub Pages | |
name: Pre-Build Checks | |
on: | |
# Runs when a pull request to main is being assigned | |
pull_request: | |
types: [ assigned, synchronize ] | |
branches: | |
- 'dev_main' | |
# Run this workflow manually from Actions tab | |
workflow_dispatch: | |
inputs: | |
branch_to_test: | |
description: 'Branch or tag to run test' | |
required: true | |
default: 'dev_main' | |
type: string | |
# Allow one concurrent deployment | |
concurrency: | |
group: ${{ github.repository }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
pre-build-checks: | |
# Run only when PR is assigned, even on subsequent commits (i.e. synchronize) | |
if: (github.event_name == 'pull_request' && github.event.pull_request.assignee != null) || github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
timeout-minutes: 40 | |
steps: | |
- name: Set Branch Variable (pull_request) | |
if: github.event_name == 'pull_request' | |
run: | | |
echo "BRANCH=${{ github.event.pull_request.head.ref }}" >> "$GITHUB_ENV" | |
echo "PR_NUM=#${{ github.event.pull_request.number }}" >> "$GITHUB_ENV" | |
- name: Set Branch Variable (workflow_dispatch) | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
echo "BRANCH=${{ inputs.branch_to_test }}" >> "$GITHUB_ENV" | |
echo "PR_NUM=#0" >> "$GITHUB_ENV" | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ env.BRANCH }} | |
submodules: recursive | |
- name: Setup python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
# Install dependencies | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
pip install pytest pytest-mock pytest-html pytest-json pytest-cov coverage httpx anybadge | |
pip install flake8 flake8-html | |
# Unit Tests & Coverage | |
- name: Unit tests with coverage | |
id: unit_tests | |
if: ${{ ! cancelled() }} | |
timeout-minutes: 30 | |
run: | | |
set +e | |
bash .ci/run-test.sh | |
source .ci/gen_pre_build_summ.sh test | |
test_status=$? | |
source .ci/gen_pre_build_summ.sh coverage | |
coverage_status=$? | |
echo "UNIT_TESTS_STATUS=$UNITTEST_SUMMARY" >> $GITHUB_ENV | |
echo "CODE_COVERAGE_STATUS=$COVERAGE_SUMMARY" >> $GITHUB_ENV | |
set -e | |
if [ $test_status -ne 0 ] || [ $coverage_status -ne 0 ]; then | |
exit 1 | |
fi | |
# Code Quality analysis - flake8 | |
- name: Code quality analysis (flake8) | |
id: code_quality | |
if: ${{ ! cancelled() }} | |
run: | | |
set +e | |
bash .ci/run-flake8.sh | |
source .ci/gen_pre_build_summ.sh lint | |
lint_status=$? | |
echo "CODE_QUALITY_STATUS=$LINT_SUMMARY" >> $GITHUB_ENV | |
set -e | |
exit $lint_status | |
# pip-audit | |
- name: Dependency analysis (vulnerabilities & licenses) | |
id: dependency_analysis | |
if: ${{ ! cancelled() }} | |
run: | | |
set +e | |
bash .ci/run-pip-audit.sh | |
source .ci/gen_pre_build_summ.sh dependency | |
dep_status=$? | |
source .ci/gen_pre_build_summ.sh license | |
lic_status=$? | |
echo "DEPENDENCY_STATUS=$DEPENDENCY_SUMMARY" >> $GITHUB_ENV | |
echo "LICENSE_STATUS=$LICENSE_SUMMARY" >> $GITHUB_ENV | |
set -e | |
if [ $dep_status -ne 0 ] || [ $lic_status -ne 0 ]; then | |
exit 1 | |
fi | |
# Send slack notification | |
- name: Send slack notification | |
if: ${{ ! cancelled() }} | |
uses: slackapi/slack-github-action@v1.26.0 | |
with: | |
payload: | | |
{ | |
"workflow": "${{ github.repository }} | ${{ github.workflow }} | ${{ env.PR_NUM }}", | |
"status": "${{ job.status }}", | |
"details": "${{ env.UNIT_TESTS_STATUS }} | ${{ env.CODE_COVERAGE_STATUS }} | ${{ env.CODE_QUALITY_STATUS }} | ${{ env.DEPENDENCY_STATUS }} | ${{ env.LICENSE_STATUS }}", | |
"ref": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |