Skip to content

Commit

Permalink
Use commit-status for upsteam workflow
Browse files Browse the repository at this point in the history
Run Scalr Provider acceptance test on merge into fatmouse master
SCALRCORE-16285
  • Loading branch information
vmotso committed Apr 29, 2021
1 parent 298e02a commit f03822f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ name: upstream
on:
workflow_dispatch:
inputs:
api_branch:
upstream-sha:
description: "Upstream commit SHA"
required: true
api-branch:
description: "API Branch"
required: true
db_branch:
db-branch:
description: "DB Branch"
required: false
default: "master"
Expand All @@ -18,17 +21,18 @@ jobs:
env:
REVIZOR_URL: ${{ secrets.REVIZOR_URL }}
REVIZOR_TOKEN: ${{ secrets.REVIZOR_TOKEN }}
ORG_ADMIN_TOKEN: ${{ secrets.ORG_ADMIN_TOKEN }}
SCALR_TOKEN: ${{ secrets.SCALR_TOKEN }}
API_BRANCH: ${{ github.event.inputs.api_branch }}
DB_BRANCH: ${{ github.event.inputs.db_branch }}
API_BRANCH: ${{ github.event.inputs.api-branch }}
DB_BRANCH: ${{ github.event.inputs.db-branch }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.13"
- name: Create container
id: create
uses: Scalr/gh-action-revizor@master
uses: Scalr/gh-action-revizor@feature/SCALRCORE-16285
with:
command: create
- name: Run acceptance tests
Expand All @@ -38,7 +42,13 @@ jobs:
- name: Delete container
id: delete
if: ${{ always() && steps.create.outputs.container_id }}
uses: Scalr/gh-action-revizor@master
uses: Scalr/gh-action-revizor@feature/SCALRCORE-16285
with:
command: delete
container_id: ${{ steps.create.outputs.container_id }}
- name: Notify upstream about success
if: ${{ success() }}
run: make notify-upstream upstream_sha=${{ github.event.inputs.upstream-sha }} state=success
- name: Notify upstream about failure
if: ${{ failure() }}
run: make notify-upstream upstream_sha=${{ github.event.inputs.upstream-sha }} state=failure
13 changes: 11 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ VERSION=$(if $(TAG),$(TAG),$(BRANCH))
USER_PLUGIN_DIR_LINUX=${HOME}/.terraform.d/plugins/scalr.io/scalr/scalr/$(VERSION)/linux_amd64
BIN_NAME := terraform-provider-scalr_$(VERSION)
ARGS=-ldflags='-X github.com/scalr/terraform-provider-scalr/version.ProviderVersion=$(TAG) -X github.com/scalr/terraform-provider-scalr/version.Branch=$(BRANCH)'
UPSTREAM_COMMIT_DESCRIPTION="Scalr terraform provider acceptance tests"
UPSTREAM_COMMIT_TARGET_URL = "https://github.com/Scalr/terraform-provider-scalr/actions/workflows/upstream.yml"

default: build

Expand All @@ -30,6 +32,14 @@ test:
testacc:
$(BUILD_ENV) TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 15m -covermode atomic -coverprofile=covprofile

notify-upstream:
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $(ORG_ADMIN_TOKEN)" \
https://api.github.com/repos/Scalr/fatmouse/statuses/$(upstream_sha) \
-d '{"context":"downstream/provider", "state":"$(state)", "description": $(UPSTREAM_COMMIT_DESCRIPTION), "target_url": $(UPSTREAM_COMMIT_TARGET_URL)}'


vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
Expand All @@ -49,5 +59,4 @@ test-compile:
exit 1; \
fi
go test -c $(TEST) $(TESTARGS)
.PHONY: build build-linux test testacc vet fmt test-compile

.PHONY: build build-linux test testacc vet fmt test-compile notify-upstream

0 comments on commit f03822f

Please sign in to comment.