Merge pull request #289 from awslabs/docs/update-terminology #441
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
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: Build and Test | |
on: | |
push: | |
branches: [ "main", "develop", "release/**" , "hotfix/**" ] | |
pull_request: | |
branches: [ "main", "develop", "release/**", "hotfix/**" ] | |
permissions: | |
contents: read | |
jobs: | |
send_starting_slack_notification: | |
name: Send Starting Slack Notification | |
runs-on: ubuntu-latest | |
steps: | |
- name: Send PR Created Notification | |
if: github.event_name == 'pull_request' && github.event.action == 'opened' | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_TITLE: 'PR Created: ${{ github.event.pull_request.title }} by ${{ github.event.pull_request.user.login }}' | |
SLACK_FOOTER: '' | |
MSG_MINIMAL: true | |
SLACK_MESSAGE: 'PR Created ${{ github.event.pull_request.html_url }}' | |
backend_build: | |
name: Backend Tests | |
runs-on: ubuntu-latest | |
needs: [send_starting_slack_notification] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
working-directory: ./backend | |
run: | | |
python -m pip install --upgrade pip | |
pip install black isort flake8 pytest | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
if [ -f test/requirements.txt ]; then pip install -r test/requirements.txt; fi | |
- name: Test with pytest | |
working-directory: ./backend | |
run: | | |
pytest --verbose \ | |
--ignore=build/private \ | |
--cov ml_space_lambda \ | |
--cov-report term-missing \ | |
--cov-report html:build/coverage \ | |
--cov-report xml:build/coverage/coverage.xml \ | |
--cov-fail-under 97 | |
frontend_build: | |
name: FrontEnd Tests | |
runs-on: ubuntu-latest | |
needs: [send_starting_slack_notification] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install dependencies | |
working-directory: ./frontend | |
run: | | |
npm install | |
- name: Run unit tests | |
working-directory: ./frontend | |
run: | | |
npm run test | |
deployment_build: | |
name: CDK Lint | |
runs-on: ubuntu-latest | |
needs: [send_starting_slack_notification] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install dependencies | |
run: | | |
npm install | |
cypress_build: | |
name: Cypress | |
runs-on: ubuntu-latest | |
needs: [send_starting_slack_notification] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install dependencies | |
run: | | |
npm install | |
- name: Lint | |
working-directory: ./cypress | |
run: | | |
npm run lint:fix | |
pre-commit: | |
name: Run All Pre-Commit | |
runs-on: ubuntu-latest | |
needs: [send_starting_slack_notification] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install dependencies Frontend | |
working-directory: ./frontend | |
run: | | |
npm install | |
- name: Install dependencies Root | |
working-directory: ./ | |
run: | | |
npm install | |
- uses: pre-commit/[email protected] | |
send_final_slack_notification: | |
name: Send Final Slack Notification | |
needs: [pre-commit, cypress_build, deployment_build, frontend_build, backend_build] | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- name: Send GitHub Action trigger data to Slack workflow | |
uses: rtCamp/action-slack-notify@v2 | |
if: github.event_name != 'pull_request' | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_COLOR: ${{ contains(join(needs.*.result, ' '), 'failure') && 'failure' || 'success' }} | |
SLACK_TITLE: 'Build Finished' | |
SLACK_FOOTER: '' | |
MSG_MINIMAL: 'actions url,commit' | |
SLACK_MESSAGE_ON_FAILURE: '<!here> Build FAILED on branch ${{ github.head_ref || github.ref_name }} for <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|commit>' | |
SLACK_MESSAGE_ON_SUCCESS: 'Build SUCCESS on branch ${{ github.head_ref || github.ref_name }} for <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|commit>.' | |
SLACK_MESSAGE: 'Build Finished with status ${{ job.status }} on branch ${{ github.head_ref || github.ref_name }} for <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|commit>' |