about summary refs log tree commit diff
path: root/.github/workflows
diff options
context:
space:
mode:
authorManuel Palenzuela Merino <manuel.palenzuela@datadoghq.com>2024-12-05 11:07:35 +0100
committerManuel Palenzuela Merino <manuel.palenzuela@datadoghq.com>2024-12-05 11:08:17 +0100
commitee3c0aa3d71a857ae7fb60f1b98cf129ee6ad71d (patch)
tree8aeaa3b76be6cdcf326acf3627b3d283a8b2c372 /.github/workflows
parentUpdate README.md (diff)
downloadtest-repo-ee3c0aa3d71a857ae7fb60f1b98cf129ee6ad71d.tar.gz
test-repo-ee3c0aa3d71a857ae7fb60f1b98cf129ee6ad71d.tar.bz2
test-repo-ee3c0aa3d71a857ae7fb60f1b98cf129ee6ad71d.zip
Add tests
Diffstat (limited to '.github/workflows')
-rw-r--r--.github/workflows/actions-test.yaml158
-rw-r--r--.github/workflows/manual-approval-test.yaml17
-rw-r--r--.github/workflows/print-env-vars.yaml15
-rw-r--r--.github/workflows/test-matrix-strategy.yml14
4 files changed, 204 insertions, 0 deletions
diff --git a/.github/workflows/actions-test.yaml b/.github/workflows/actions-test.yaml
new file mode 100644
index 0000000..bce30b2
--- /dev/null
+++ b/.github/workflows/actions-test.yaml
@@ -0,0 +1,158 @@
+name: Testing Github actions
+on: [push]
+
+jobs:
+
+  datadog-tags:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - name: Install node
+        uses: actions/setup-node@v3
+      - run: yarn global add @datadog/datadog-ci
+      - run: DD_API_KEY=${{ secrets.DD_API_KEY }} DD_APP_KEY=${{ secrets.DD_APP_KEY }} DD_SITE='datad0g.com' DD_TAGS='team:civisibility,service:my-custom-service-3' datadog-ci tag --level pipeline
+      - run: DD_API_KEY=${{ secrets.DD_API_KEY }} DD_APP_KEY=${{ secrets.DD_APP_KEY }} DD_SITE='datad0g.com' datadog-ci metric --level pipeline --metrics image_size:150
+      - run: DD_API_KEY=${{ secrets.DD_API_KEY_PROD }} DD_APP_KEY=${{ secrets.DD_APP_KEY_PROD }} datadog-ci tag --level pipeline --tags team:civisibility
+      - run: DD_API_KEY=${{ secrets.DD_API_KEY_PROD }} DD_APP_KEY=${{ secrets.DD_APP_KEY_PROD }} datadog-ci metric --level pipeline --metrics image_size:150
+
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-go@v3
+        with:
+          go-version: '>=1.17.0'
+      - run: go build ./main/...
+
+  test-additions:
+    needs: build
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-go@v3
+        with:
+          go-version: '>=1.17.0'
+      - run: go install gotest.tools/gotestsum@latest
+      - run: gotestsum --junitfile additions-test.xml ./main/additions/...
+      - name: Uploading test results
+        if: always()
+        run: |
+            yarn global add @datadog/datadog-ci
+            export DATADOG_API_KEY=${{ secrets.DD_API_KEY }}
+            export DATADOG_SITE='datad0g.com'
+            export DD_ENV=ci-tests-ubuntu-latest
+            datadog-ci junit upload --service ci-visibility-test-additions --report-tags test_level:session --report-metrics=test.code_coverage.lines_pct:85 additions-test.xml
+  
+  test-subtractions:
+    needs: build
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-go@v3
+        with:
+          go-version: '>=1.17.0'
+      - run: go install gotest.tools/gotestsum@latest
+      - run: gotestsum --junitfile subtractions-test.xml ./main/subtractions/...
+      - name: Uploading test results
+        if: always()
+        run: |
+            yarn global add @datadog/datadog-ci
+            export DATADOG_API_KEY=${{ secrets.DD_API_KEY }}
+            export DATADOG_SITE='datad0g.com'
+            export DD_ENV=ci-tests-ubuntu-latest
+            datadog-ci junit upload --service ci-visibility-test-subtractions --report-tags test_level:session --report-metrics=test.code_coverage.lines_pct:25 subtractions-test.xml
+  
+  test-subtractions-2:
+    needs: build
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-go@v3
+        with:
+          go-version: '>=1.17.0'
+      - run: go install gotest.tools/gotestsum@latest
+      - run: gotestsum --junitfile subtractions-test.xml ./main/subtractions/...
+      - name: Uploading test results
+        if: always()
+        run: |
+            yarn global add @datadog/datadog-ci
+            export DATADOG_API_KEY=${{ secrets.DD_API_KEY }}
+            export DATADOG_SITE='datad0g.com'
+            export DD_ENV=ci-tests-ubuntu-latest
+            datadog-ci junit upload --service ci-visibility-test-subtractions --report-tags test_level:session --report-tags runtime.version:test --report-metrics=test.code_coverage.lines_pct:44 subtractions-test.xml
+
+  python-tests:
+    needs: build
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-python@v4
+        with:
+          python-version: '3.x'
+      - run: pip install pytest ddtrace coverage
+      - name: Configure Datadog Test Visibility
+        uses: datadog/test-visibility-github-action@v2
+        with:
+          languages: python
+          api_key: ${{ secrets.DD_API_KEY }}
+          site: datad0g.com
+      - name: Running tests
+        if: always()
+        run: pytest
+  
+  tagged_job:
+    runs-on: ubuntu-latest
+    name: Custom tagged job
+    env:
+      DD_GITHUB_JOB_NAME: Custom tagged job
+    steps:
+      - uses: actions/checkout@v3
+      - name: Install node
+        uses: actions/setup-node@v3
+      - run: yarn global add @datadog/datadog-ci
+      - run: >
+          DATADOG_API_KEY=${{ secrets.DD_API_KEY }}
+          DATADOG_SITE='datad0g.com'
+          datadog-ci tag --level job --tags "custom_tag:1234"
+
+  datadog-gate:
+    needs: [test-additions, test-subtractions, test-subtractions-2, python-tests]
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - name: Install node
+        uses: actions/setup-node@v3
+      - run: yarn global add @datadog/datadog-ci
+      - run: >
+          DD_API_KEY=${{ secrets.DD_API_KEY }}
+          DD_APP_KEY=${{ secrets.DD_APP_KEY }}
+          DD_SITE='datad0g.com'
+          datadog-ci gate evaluate --scope=team:backend --scope=team:frontend
+  datadog-frontend-tests:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - name: Run frontend tests
+        uses: actions/setup-node@v3
+      - run: yarn global add @datadog/datadog-ci
+      - run: >
+          DATADOG_API_KEY=${{ secrets.DD_API_KEY }}
+          DATADOG_SITE='datad0g.com'
+          datadog-ci tag --level pipeline --tags team:ci-visibility-app
+
+  test-additions-with-ddtrace:
+    needs: build
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-go@v3
+        with:
+          go-version: '>=1.17.0'
+      - name: Uploading test results
+        if: always()
+        run: |
+            export DD_API_KEY=${{ secrets.DD_API_KEY }}
+            export DD_SITE='datad0g.com'
+            export DD_SERVICE=ci-visibility-additions-ddtrace
+            export DD_CIVISIBILITY_AGENTLESS_ENABLED=true
+            go test ./main/additions/...
diff --git a/.github/workflows/manual-approval-test.yaml b/.github/workflows/manual-approval-test.yaml
new file mode 100644
index 0000000..e861181
--- /dev/null
+++ b/.github/workflows/manual-approval-test.yaml
@@ -0,0 +1,17 @@
+name: CI/CD with Manual Approval
+on: workflow_dispatch
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v2
+
+  deploy:
+    runs-on: ubuntu-latest
+    needs: build
+    environment:
+      name: TEST_APPROVALS
+    steps:
+      - name: My Manual Approval step
+        run: sleep 5
diff --git a/.github/workflows/print-env-vars.yaml b/.github/workflows/print-env-vars.yaml
new file mode 100644
index 0000000..e0e5fa4
--- /dev/null
+++ b/.github/workflows/print-env-vars.yaml
@@ -0,0 +1,15 @@
+name: Printing env variables
+
+on: [push]
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    name: printer
+    steps:
+      - name: Print GitHub context
+        env:
+          GITHUB_CONTEXT: ${{ toJson(github) }}
+        run: echo "$GITHUB_CONTEXT"
+      - name: Print github_sha
+        run: echo "$GITHUB_SHA"
diff --git a/.github/workflows/test-matrix-strategy.yml b/.github/workflows/test-matrix-strategy.yml
new file mode 100644
index 0000000..6233ab8
--- /dev/null
+++ b/.github/workflows/test-matrix-strategy.yml
@@ -0,0 +1,14 @@
+name: CI
+
+on: [workflow_dispatch]
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    name: matrix ${{ matrix.version }}
+    strategy:
+      matrix:
+        version: [10, 12, 14]
+    steps:
+      - uses: actions/checkout@v3
+      - run: sleep ${{ matrix.version }}