diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 186d2b42..ac9771a6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,6 +6,11 @@ on: - alpha - main workflow_dispatch: + schedule: + # every sunday at 00:00 + # - cron: '0 0 * * 0' + # every day at 00:00 + - cron: '0 0 * * *' push: branches: - '!main' @@ -100,7 +105,9 @@ jobs: --version=${VERSION} + main: + if: ${{ github.event_name != 'schedule' }} name: CI runs-on: ubuntu-latest needs: config @@ -146,6 +153,7 @@ jobs: path: "stackit/${{ env.CODE_COVERAGE_FILE_NAME }}" config: + if: ${{ github.event_name != 'schedule' }} name: Check GoReleaser config runs-on: ubuntu-latest steps: diff --git a/Makefile b/Makefile index 9a14779b..f678f099 100644 --- a/Makefile +++ b/Makefile @@ -34,8 +34,7 @@ fmt: @terraform fmt -diff -recursive # TEST -.PHONY: test-full test coverage -test-full: test coverage +.PHONY: test coverage test: @echo "Running tests for the terraform provider" @cd $(ROOT_DIR)/stackit && go test ./... -count=1 -coverprofile=../coverage.out && cd $(ROOT_DIR) diff --git a/stackit/provider_acc_test.go b/stackit/provider_acc_test.go index 6ad0615f..f520d574 100644 --- a/stackit/provider_acc_test.go +++ b/stackit/provider_acc_test.go @@ -31,7 +31,12 @@ var providerValidAttributes string var testConfigProviderCredentials = config.Variables{ "project_id": config.StringVariable(testutil.ProjectId), - "name": config.StringVariable(fmt.Sprintf("tf-acc-prov%s", acctest.RandStringFromCharSet(3, acctest.CharSetAlphaNum))), + "name": config.StringVariable( + fmt.Sprintf( + "tf-acc-prov%s", + acctest.RandStringFromCharSet(3, acctest.CharSetAlphaNum), + ), + ), } func setup() { @@ -129,14 +134,6 @@ func cleanupTemporaryHome(tempHomePath string, t *testing.T) { } } -func getServiceAccountToken() (string, error) { - token, set := os.LookupEnv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN") - if !set || token == "" { - return "", fmt.Errorf("Token not set, please set TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN to a valid token to perform tests") - } - return token, nil -} - func TestAccEnvVarTokenValid(t *testing.T) { // Check if acceptance tests should be run if v := os.Getenv(resource.EnvTfAcc); v == "" { @@ -146,13 +143,7 @@ func TestAccEnvVarTokenValid(t *testing.T) { return } - token, err := getServiceAccountToken() - if err != nil { - t.Fatalf("Can't get token: %v", err) - } - t.Setenv("STACKIT_CREDENTIALS_PATH", "") - t.Setenv("STACKIT_SERVICE_ACCOUNT_TOKEN", token) tempHomeFolder := createTemporaryHome(false, t) defer cleanupTemporaryHome(tempHomeFolder, t) resource.Test(t, resource.TestCase{