Rename integrations-tools-and-libraries to api-clients in CODEOWNERS #269
Workflow file for this run
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: Run Contract Tests | |
# env: | |
# GIT_AUTHOR_EMAIL: "packages@datadoghq.com" | |
# GIT_AUTHOR_NAME: "ci.datadog-cloudformation-resources" | |
on: | |
pull_request: | |
branches: | |
- master | |
concurrency: | |
group: contract-${{ github.head_ref }} | |
cancel-in-progress: true | |
jobs: | |
# pre-commit: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v3 | |
# with: | |
# fetch-depth: 0 | |
# - uses: actions/setup-python@v4 | |
# with: | |
# python-version: '3.9' | |
# - name: Install pre-commit | |
# run: python -m pip install pre-commit | |
# - uses: actions/cache@v3 | |
# with: | |
# path: ~/.cache/pre-commit | |
# key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} | |
# - id: pre_commit | |
# name: Run pre-commit | |
# if: github.event.action != 'closed' && github.event.pull_request.merged != true | |
# run: | | |
# pre-commit run --from-ref "${FROM_REF}" --to-ref "${TO_REF}" --show-diff-on-failure --color=always | |
# env: | |
# FROM_REF: ${{ github.event.pull_request.base.sha }} | |
# TO_REF: ${{ github.event.pull_request.head.sha }} | |
# - name: Commit changes | |
# if: ${{ failure() }} | |
# run: |- | |
# git add -A | |
# git config user.name "${GIT_AUTHOR_NAME}" | |
# git config user.email "${GIT_AUTHOR_EMAIL}" | |
# git commit -m "pre-commit fixes" | |
# git push origin "HEAD:${HEAD_REF}" | |
# exit 1 | |
# env: | |
# HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
find_modified_resources: | |
# needs: pre-commit | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get changed files | |
id: changed_files | |
uses: tj-actions/changed-files@v8.4 | |
outputs: | |
changed_files: ${{ steps.changed_files.outputs.all_changed_files }} | |
test: | |
needs: find_modified_resources | |
strategy: | |
fail-fast: false | |
matrix: | |
resource: | |
- datadog-dashboards-dashboard-handler | |
- datadog-monitors-monitor-handler | |
- datadog-monitors-downtime-handler | |
- datadog-monitors-downtimeschedule-handler | |
- datadog-integrations-aws-handler | |
- datadog-slos-slo-handler | |
# - datadog-iam-user-handler | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.draft == false | |
steps: | |
- name: Install Python | |
if: contains(needs.find_modified_resources.outputs.changed_files, matrix.resource) | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- uses: aws-actions/setup-sam@v1 | |
if: contains(needs.find_modified_resources.outputs.changed_files, matrix.resource) | |
- name: Checkout code | |
if: contains(needs.find_modified_resources.outputs.changed_files, matrix.resource) | |
uses: actions/checkout@v3 | |
- name: Install Deps | |
if: contains(needs.find_modified_resources.outputs.changed_files, matrix.resource) | |
run: pip install --disable-pip-version-check -e ./datadog-cloudformation-common-python[build] | |
- name: Install pre-commit | |
if: contains(needs.find_modified_resources.outputs.changed_files, matrix.resource) | |
run: python -m pip install pre-commit | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit|${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Check generated files are up-to-date | |
if: contains(needs.find_modified_resources.outputs.changed_files, matrix.resource) | |
run: | | |
cd ${{ matrix.resource }} | |
cfn generate | |
set +e | |
pre-commit run --all-files | |
git diff --exit-code | |
if [ $? -ne 0 ]; then | |
echo "'cfn generate and pre-commit run --all-files' generated changes. Run it locally and commit the changes." | |
exit 1 | |
fi | |
set -e | |
- name: Build Package | |
if: contains(needs.find_modified_resources.outputs.changed_files, matrix.resource) | |
run: | | |
cd ${{ matrix.resource }} | |
cfn submit --dry-run --no-role | |
- name: Create Type Configuration | |
if: contains(needs.find_modified_resources.outputs.changed_files, matrix.resource) | |
run: | | |
mkdir ~/.cfn-cli | |
echo "{\"DatadogCredentials\":{\"ApiKey\":\"${DD_TEST_CLIENT_API_KEY}\",\"ApplicationKey\":\"${DD_TEST_CLIENT_APP_KEY}\"}}" > ~/.cfn-cli/typeConfiguration.json | |
env: | |
DD_TEST_CLIENT_API_KEY: ${{ secrets.DD_TEST_CLIENT_API_KEY }} | |
DD_TEST_CLIENT_APP_KEY: ${{ secrets.DD_TEST_CLIENT_APP_KEY }} | |
- name: Run Tests | |
if: contains(needs.find_modified_resources.outputs.changed_files, matrix.resource) | |
run: | | |
cd ${{ matrix.resource }} | |
sam local start-lambda & | |
cfn test --role-arn arn:aws:iam::088054601418:role/cf-contract-tests-ci | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |