|
| 1 | +name: Run benchmark tests for master |
| 2 | +on: |
| 3 | + workflow_run: |
| 4 | + workflows: [ 'Run integration tests for master' ] |
| 5 | + types: |
| 6 | + - completed |
| 7 | +jobs: |
| 8 | + run-benchmark-gcp: |
| 9 | + name: run-benchmark on GCP - k8s ${{ matrix.k8s-release }} |
| 10 | + if: github.event.workflow_run.conclusion == 'success' |
| 11 | + strategy: |
| 12 | + max-parallel: 3 |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + k8s-release: [ '1.19', '1.20' ] #, 1.19/stable, 1.18/stable ] |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v2 |
| 19 | + with: |
| 20 | + repository: calyptia/fluent-bit-ci |
| 21 | + path: ci |
| 22 | + |
| 23 | + - uses: frabert/replace-string-action@master |
| 24 | + id: formatted_release |
| 25 | + with: |
| 26 | + pattern: '(.*)\.(.*)$' |
| 27 | + string: ${{ matrix.k8s-release }} |
| 28 | + replace-with: '$1-$2' |
| 29 | + flags: 'g' |
| 30 | + |
| 31 | + - name: Replace the k8s release |
| 32 | + run: | |
| 33 | + sed -i -e "s/\$K8S_RELEASE/${{ env.k8s_release }}/g" default.auto.tfvars |
| 34 | + sed -i -e "s/\$K8S_FORMATTED/${{ env.k8s_release_formatted }}/g" default.auto.tfvars |
| 35 | + sed -i -e "s/\$K8S_FORMATTED/${{ env.k8s_release_formatted }}/g" config.tf |
| 36 | + working-directory: ci/terraform/gcp/ |
| 37 | + env: |
| 38 | + k8s_release: ${{ matrix.k8s-release }} |
| 39 | + k8s_release_formatted: ${{ steps.formatted_release.outputs.replaced }} |
| 40 | + |
| 41 | + - uses: hashicorp/setup-terraform@v1 |
| 42 | + with: |
| 43 | + cli_config_credentials_hostname: 'app.terraform.io' |
| 44 | + cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} |
| 45 | + |
| 46 | + - name: Replace the GCP service account key |
| 47 | + run: | |
| 48 | + cat <<EOT >> default.auto.tfvars |
| 49 | + gcp-sa-key = <<-EOF |
| 50 | + ${{ secrets.GCP_SA_KEY }} |
| 51 | + EOF |
| 52 | + EOT |
| 53 | + working-directory: ci/terraform/gcp/ |
| 54 | + |
| 55 | + - name: Terraform fmt |
| 56 | + id: fmt |
| 57 | + run: terraform fmt -check |
| 58 | + continue-on-error: true |
| 59 | + working-directory: ci/terraform/gcp/ |
| 60 | + |
| 61 | + - name: Terraform Init |
| 62 | + id: init |
| 63 | + run: terraform init |
| 64 | + working-directory: ci/terraform/gcp/ |
| 65 | + |
| 66 | + - name: Terraform Validate |
| 67 | + id: validate |
| 68 | + run: terraform validate -no-color |
| 69 | + working-directory: ci/terraform/gcp/ |
| 70 | + |
| 71 | + - name: Terraform Apply |
| 72 | + id: apply |
| 73 | + run: | |
| 74 | + terraform apply -input=false -auto-approve |
| 75 | + working-directory: ci/terraform/gcp/ |
| 76 | + |
| 77 | + - name: Get the k8s cluster name from terraform output |
| 78 | + id: get-k8s-cluster-name |
| 79 | + run: terraform output -no-color -raw k8s-cluster-name |
| 80 | + working-directory: ci/terraform/gcp/ |
| 81 | + |
| 82 | + - name: Get the k8s cluster location from terraform output |
| 83 | + id: get-k8s-cluster-location |
| 84 | + run: terraform output -no-color -raw k8s-cluster-location |
| 85 | + working-directory: ci/terraform/gcp/ |
| 86 | + |
| 87 | + - name: Get the k8s project id from terraform output |
| 88 | + id: get-gcp-project-id |
| 89 | + run: terraform output -no-color -raw gcp-project-id |
| 90 | + working-directory: ci/terraform/gcp/ |
| 91 | + |
| 92 | + - uses: google-github-actions/setup-gcloud@master |
| 93 | + with: |
| 94 | + service_account_key: ${{ secrets.GCP_SA_KEY }} |
| 95 | + |
| 96 | + - uses: google-github-actions/get-gke-credentials@main |
| 97 | + with: |
| 98 | + cluster_name: ${{ steps.get-k8s-cluster-name.outputs.stdout }} |
| 99 | + location: ${{ steps.get-k8s-cluster-location.outputs.stdout }} |
| 100 | + credentials: ${{ secrets.GCP_SA_KEY }} |
| 101 | + |
| 102 | + - uses: actions/setup-go@v2 |
| 103 | + with: |
| 104 | + go-version: '1.15' # The Go version to download (if necessary) and use. |
| 105 | + |
| 106 | + - uses: azure/setup-helm@v1 |
| 107 | + id: install |
| 108 | + |
| 109 | + - run: go mod download |
| 110 | + working-directory: ci/integration/ |
| 111 | + |
| 112 | + - run: make benchmark |
| 113 | + env: |
| 114 | + IMAGE_REPOSITORY: fluentbitdev/fluent-bit |
| 115 | + IMAGE_TAG: x86_64-master |
| 116 | + GRAFANA_USERNAME: ${{ secrets.GRAFANA_USERNAME }} |
| 117 | + GRAFANA_PASSWORD: ${{ secrets.GRAFANA_PASSWORD }} |
| 118 | + working-directory: ci/ |
0 commit comments