Skip to content

Commit

Permalink
Converting to GitHub Actions (#7)
Browse files Browse the repository at this point in the history
Forcibly merging in spite of failures, as those failures were also happening on Codeship
  • Loading branch information
taiidani committed May 2, 2020
1 parent 2020e99 commit e371733
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 37 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Acceptance Tests

on: pull_request

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- run: go mod download

- name: Set up services
env:
COMPOSE_FILE: ./.github/workflows/acceptance/docker-compose.yml
run: |
docker-compose build
docker-compose up -d --force-recreate jenkins
while [ "$(docker inspect jenkins-provider-acc --format '{{ .State.Health.Status }}')" != "healthy" ]; do echo "Waiting for Jenkins to start..."; sleep 3; done
- name: Run Acceptance Tests
env:
TF_ACC: "1"
JENKINS_URL: "http://localhost:8080"
JENKINS_USERNAME: "admin"
JENKINS_PASSWORD: "admin"
run: go test -v -cover ./...
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
build:
context: .
dockerfile: Dockerfile
ports:
- 8080:8080
container_name: jenkins-provider-acc
environment:
JAVA_OPTS: "-Djenkins.install.runSetupWizard=false"
23 changes: 23 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Unit Tests

on: [ push ]

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- run: go mod download
- run: go vet ./...
- run: go test -cover ./...
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This is a community provider and is not supported by Hashicorp.
## Requirements

- [Terraform](https://www.terraform.io/downloads.html) 0.10+
- [Go](https://golang.org/doc/install) 1.11 (to build the provider plugin)
- [Go](https://golang.org/doc/install) 1.11+ (to build the provider plugin)

## Installation

Expand Down Expand Up @@ -37,7 +37,7 @@ In order to test the provider, you can simply run `make test`.
$ make test
```

In order to run the full suite of Acceptance tests, run `make testacc`. These tests require Docker installed on the machine that run them, and do not create any remote resources.
In order to run the full suite of Acceptance tests, run `make testacc`. These tests require Docker to be installed on the machine that runs them, and do not create any remote resources.

```sh
$ make testacc
Expand Down
17 changes: 0 additions & 17 deletions codeship-services.yml

This file was deleted.

3 changes: 0 additions & 3 deletions codeship-steps.yml

This file was deleted.

7 changes: 0 additions & 7 deletions codeship.dockerfile

This file was deleted.

2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/taiidani/terraform-provider-jenkins

go 1.14

require (
github.com/apparentlymart/go-cidr v1.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
Expand Down
14 changes: 6 additions & 8 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
BINARY=terraform-provider-jenkins
ACC_DOCKER_URL=localhost
ACC_USE_DOCKER=true
export COMPOSE_FILE=./jenkins/test-fixtures/docker-compose.yml
export COMPOSE_FILE=./.github/workflows/acceptance/docker-compose.yml

default: build

Expand All @@ -19,11 +17,11 @@ test:

# Executes all acceptance tests for the provider
testacc:
@if [ "${ACC_USE_DOCKER}" == "true" ]; then docker-compose build; fi
@if [ "${ACC_USE_DOCKER}" == "true" ]; then docker-compose up -d --force-recreate jenkins; fi
@if [ "${ACC_USE_DOCKER}" == "true" ]; then while [ "$$(docker inspect jenkins-provider-acc --format '{{ .State.Health.Status }}')" != "healthy" ]; do echo "Waiting for Jenkins to start..."; sleep 3; done; fi
TF_ACC=1 JENKINS_URL="http://${ACC_DOCKER_URL}:8080" JENKINS_USERNAME="admin" JENKINS_PASSWORD="admin" go test -v -cover ./...
@if [ "${ACC_USE_DOCKER}" == "true" ]; then docker-compose down; fi
@docker-compose build
@docker-compose up -d --force-recreate jenkins
@while [ "$$(docker inspect jenkins-provider-acc --format '{{ .State.Health.Status }}')" != "healthy" ]; do echo "Waiting for Jenkins to start..."; sleep 3; done
TF_ACC=1 JENKINS_URL="http://localhost:8080" JENKINS_USERNAME="admin" JENKINS_PASSWORD="admin" go test -v -cover ./...
@docker-compose down

# Cleans up any lingering items in your system created by this provider.
clean:
Expand Down

0 comments on commit e371733

Please sign in to comment.