From 47cd4132291e47f60857217e4e1aaa897f33666f Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Thu, 12 Aug 2021 16:27:36 +0200 Subject: [PATCH] Run tests in CI Signed-off-by: Marco Pracucci --- .github/workflows/codeql-analysis.yml | 67 -------------- .github/workflows/funcbench.yml | 58 ------------ .github/workflows/fuzzing.yml | 29 ------ .github/workflows/prombench.yml | 126 -------------------------- .github/workflows/test.yml | 53 +++++++++++ 5 files changed, 53 insertions(+), 280 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml delete mode 100644 .github/workflows/funcbench.yml delete mode 100644 .github/workflows/fuzzing.yml delete mode 100644 .github/workflows/prombench.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index fb8c96aba..000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,67 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [main, release-*] - pull_request: - # The branches below must be a subset of the branches above - branches: [main] - schedule: - - cron: "26 14 * * 1" - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - language: ["go", "javascript"] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more: - # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/funcbench.yml b/.github/workflows/funcbench.yml deleted file mode 100644 index 6583aa95b..000000000 --- a/.github/workflows/funcbench.yml +++ /dev/null @@ -1,58 +0,0 @@ -on: - repository_dispatch: - types: [funcbench_start] -name: Funcbench Workflow -jobs: - run_funcbench: - name: Running funcbench - if: github.event.action == 'funcbench_start' - runs-on: ubuntu-latest - env: - AUTH_FILE: ${{ secrets.TEST_INFRA_PROVIDER_AUTH }} - BRANCH: ${{ github.event.client_payload.BRANCH }} - BENCH_FUNC_REGEX: ${{ github.event.client_payload.BENCH_FUNC_REGEX }} - PACKAGE_PATH: ${{ github.event.client_payload.PACKAGE_PATH }} - GITHUB_TOKEN: ${{ secrets.PROMBOT_TOKEN }} - GITHUB_ORG: prometheus - GITHUB_REPO: prometheus - GITHUB_STATUS_TARGET_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} - LAST_COMMIT_SHA: ${{ github.event.client_payload.LAST_COMMIT_SHA }} - GKE_PROJECT_ID: macro-mile-203600 - PR_NUMBER: ${{ github.event.client_payload.PR_NUMBER }} - PROVIDER: gke - ZONE: europe-west3-a - steps: - - name: Update status to pending - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"pending","context":"funcbench-status","target_url":"'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Prepare nodepool - uses: docker://prominfra/funcbench:master - with: - entrypoint: "docker_entrypoint" - args: make deploy - - name: Delete all resources - if: always() - uses: docker://prominfra/funcbench:master - with: - entrypoint: "docker_entrypoint" - args: make clean - - name: Update status to failure - if: failure() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"failure","context":"funcbench-status","target_url":"'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Update status to success - if: success() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"success","context":"funcbench-status","target_url":"'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml deleted file mode 100644 index eb4a76d54..000000000 --- a/.github/workflows/fuzzing.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: CIFuzz -on: - pull_request: - paths: - - "go.sum" - - "go.mod" - - "**.go" -jobs: - Fuzzing: - runs-on: ubuntu-latest - steps: - - name: Build Fuzzers - id: build - uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master - with: - oss-fuzz-project-name: "prometheus" - dry-run: false - - name: Run Fuzzers - uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master - with: - oss-fuzz-project-name: "prometheus" - fuzz-seconds: 600 - dry-run: false - - name: Upload Crash - uses: actions/upload-artifact@v1 - if: failure() && steps.build.outcome == 'success' - with: - name: artifacts - path: ./out/artifacts diff --git a/.github/workflows/prombench.yml b/.github/workflows/prombench.yml deleted file mode 100644 index 6ee172662..000000000 --- a/.github/workflows/prombench.yml +++ /dev/null @@ -1,126 +0,0 @@ -on: - repository_dispatch: - types: [prombench_start, prombench_restart, prombench_stop] -name: Prombench Workflow -env: - AUTH_FILE: ${{ secrets.TEST_INFRA_PROVIDER_AUTH }} - CLUSTER_NAME: test-infra - DOMAIN_NAME: prombench.prometheus.io - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_ORG: prometheus - GITHUB_REPO: prometheus - GITHUB_STATUS_TARGET_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} - LAST_COMMIT_SHA: ${{ github.event.client_payload.LAST_COMMIT_SHA }} - GKE_PROJECT_ID: macro-mile-203600 - PR_NUMBER: ${{ github.event.client_payload.PR_NUMBER }} - PROVIDER: gke - RELEASE: ${{ github.event.client_payload.RELEASE }} - ZONE: europe-west3-a -jobs: - benchmark_start: - name: Benchmark Start - if: github.event.action == 'prombench_start' - runs-on: ubuntu-latest - steps: - - name: Update status to pending - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"pending", "context": "prombench-status-update-start", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Run make deploy to start test - id: make_deploy - uses: docker://prominfra/prombench:master - with: - args: >- - until make all_nodes_deleted; do echo "waiting for nodepools to be deleted"; sleep 10; done; - make deploy; - - name: Update status to failure - if: failure() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"failure", "context": "prombench-status-update-start", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Update status to success - if: success() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"success", "context": "prombench-status-update-start", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - benchmark_cancel: - name: Benchmark Cancel - if: github.event.action == 'prombench_stop' - runs-on: ubuntu-latest - steps: - - name: Update status to pending - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"pending", "context": "prombench-status-update-cancel", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Run make clean to stop test - id: make_clean - uses: docker://prominfra/prombench:master - with: - args: >- - until make all_nodes_running; do echo "waiting for nodepools to be created"; sleep 10; done; - make clean; - - name: Update status to failure - if: failure() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"failure", "context": "prombench-status-update-cancel", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Update status to success - if: success() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"success", "context": "prombench-status-update-cancel", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - benchmark_restart: - name: Benchmark Restart - if: github.event.action == 'prombench_restart' - runs-on: ubuntu-latest - steps: - - name: Update status to pending - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"pending", "context": "prombench-status-update-restart", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Run make clean then make deploy to restart test - id: make_restart - uses: docker://prominfra/prombench:master - with: - args: >- - until make all_nodes_running; do echo "waiting for nodepools to be created"; sleep 10; done; - make clean; - until make all_nodes_deleted; do echo "waiting for nodepools to be deleted"; sleep 10; done; - make deploy; - - name: Update status to failure - if: failure() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"failure", "context": "prombench-status-update-restart", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Update status to success - if: success() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"success", "context": "prombench-status-update-restart", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..cda79f5f4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,53 @@ +name: ci +on: + push: + branches: [main] + pull_request: + +jobs: +# lint: +# runs-on: ubuntu-20.04 +# container: +# image: us.gcr.io/kubernetes-dev/mimir-build-image:jdb-lint-packaging-scripts-b6709b71a +# credentials: +# username: _json_key +# password: ${{ secrets.gcr_json_key }} +# steps: +# - name: Checkout Repo +# uses: actions/checkout@v2 +# # Commands in the Makefile are hardcoded with an assumed file structure of the CI container +# # Symlink ensures paths specified in previous commands don’t break +# - name: Symlink Expected Path to Workspace +# run: | +# mkdir -p /go/src/github.com/grafana/mimir +# ln -s $GITHUB_WORKSPACE/* /go/src/github.com/grafana/mimir +# - name: Lint +# run: make BUILD_IN_CONTAINER=false lint +# - name: Check Vendor Directory +# run: | +# git config --global url."https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/grafana/prometheus-private".insteadOf "https://github.com/grafana/prometheus-private" +# make BUILD_IN_CONTAINER=false mod-check +# env: +# GIT_PASSWORD: ${{ secrets.GIT_PASSWORD }} +# GIT_USERNAME: ${{ secrets.GIT_USERNAME }} +# - name: Check Protos +# run: make BUILD_IN_CONTAINER=false check-protos +# - name: Check Generated Documentation +# run: make BUILD_IN_CONTAINER=false check-doc +# - name: Check White Noise. +# run: make BUILD_IN_CONTAINER=false check-white-noise +# - name: Check License Header +# run: make BUILD_IN_CONTAINER=false check-license + + test: + runs-on: ubuntu-20.04 +# container: +# image: us.gcr.io/kubernetes-dev/mimir-build-image:jdb-lint-packaging-scripts-b6709b71a +# credentials: +# username: _json_key +# password: ${{ secrets.gcr_json_key }} + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Run Tests + run: make common-test