Lint #1650
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: Lint | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
schedule: | |
- cron: '0 4 * * *' | |
permissions: | |
actions: write # Needed for skip-duplicate-jobs job | |
contents: read | |
jobs: | |
# Special job which automatically cancels old runs for the same branch, prevents runs for the | |
# same file set which has already passed, etc. | |
pre_job: | |
name: Skip Duplicate Jobs Pre Job | |
runs-on: ubuntu-latest | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@12aca0a884f6137d619d6a8a09fcc3406ced5281 # v4.0.0 | |
with: | |
cancel_others: 'true' | |
github_token: ${{ github.token }} | |
tox-lint: | |
runs-on: ubuntu-20.04 | |
needs: pre_job | |
# NOTE: We always want to run job on master branch | |
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref_name == 'master' }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 | |
- name: Install Latest Stable Shellcheck | |
run: | | |
wget https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz | |
tar xvf shellcheck-stable.linux.x86_64.tar.xz | |
sudo cp shellcheck-stable/shellcheck /usr/local/bin | |
rm -rf shellcheck-stable* | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
id: setup-python | |
with: | |
python-version: 3.6.15 | |
- name: Install tox | |
env: | |
TOX_VERSION: 3.20.1 | |
TOX_GH_ACTIONS_VERSION: 2.9.1 | |
run: | | |
python -m pip install --upgrade pip | |
pip install "tox==$TOX_VERSION" "tox-gh-actions==$TOX_GH_ACTIONS_VERSION" requests | |
- name: Run tox lint target | |
run: tox -e lint | |
- name: Verify Codecov config | |
# Small safety check to make sure the build fails if codecov.yml file is invalid. | |
# By default codecov doesn't fail on invalid config and simply falls back to | |
# system wide default config in case repo local config is invalid. This usually results | |
# in confused and undesired behavior. | |
run: ./scripts/circleci/verify-codecov-config.sh | |
- name: Verify add events api response headers | |
# Runs script which verifies /addEvents API returns correct response headers. In ideal | |
# world, this script would live somewhere else (perhaps as part of monitoring tooling, | |
# but for now it will live here. | |
env: | |
PYTHONPATH: . | |
SCALYR_TOKEN_PROD_US: ${{ secrets.CT_SCALYR_TOKEN_PROD_US_CLOUDTECH_TESTING_WRITE }} | |
SCALYR_TOKEN_PROD_EU: ${{ secrets.CT_SCALYR_TOKEN_PROD_EU_MONITOR_WRITE }} | |
SCALYR_TOKEN_STAGING_EU: ${{ secrets.CT_SCALYR_TOKEN_STAGING_EU_PROD_WRITE }} | |
run: ./scripts/verify-add-events-api-response-headers.py | |
- name: Run Shell Scripts Lint Checks | |
env: | |
IGNORE_BINARY_DOESNT_EXIST: "0" | |
run: ./scripts/shell-scripts-lint.sh | |
- name: Generate Monitor Docs | |
run: | | |
tox -e generate-monitor-docs | |
# Verify there are no changes after generating the docs. If there | |
# are, this indicates developer didn't run this target locally and | |
# that some files are not up to date | |
git status | |
git status -- *docs/monitors/*.md */docs/monitorsDmd | (grep -q "nothing to commit" || (echo "Auto-generate monitor doc files are not up to date. Make sure you run tox -e generate-monitor-docs and commit any changed files." && exit 1)) | |
- name: Notify Slack on Failure | |
if: ${{ failure() && github.ref_name == 'master' }} | |
uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f # v2.0.0 | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
with: | |
status: ${{ job.status }} | |
steps: ${{ toJson(steps) }} | |
channel: '#eng-dataset-cloud-tech' |