diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..888a5a7 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,42 @@ +name: Go +on: [push] +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + # TODO: convert this to `services` + - name: Start Unifi controller + run: | + ./controller.sh + + - name: Get dependencies + run: | + go mod download + + - name: Build + run: | + go build -v . + + - name: TF acceptance tests + timeout-minutes: 10 + env: + TF_ACC: "1" + + UNIFI_USERNAME: tfacctest + UNIFI_PASSWORD: tfacctest1234 + UNIFI_API: https://localhost:8443/api/ + UNIFI_ACC_WLAN_CONCURRENCY: "4" + run: | + go test -v -cover ./internal/provider/ diff --git a/controller.sh b/controller.sh old mode 100644 new mode 100755 index 131798d..dfae05b --- a/controller.sh +++ b/controller.sh @@ -1,28 +1,20 @@ #! /bin/bash -# docker run \ -# --name=unifi-controller \ -# -e PUID=1000 \ -# -e PGID=1000 \ -# -e MEM_LIMIT=1024M `#optional` \ -# -p 3478:3478/udp \ -# -p 10001:10001/udp \ -# -p 8080:8080 \ -# -p 8081:8081 \ -# -p 8443:8443 \ -# -p 8843:8843 \ -# -p 8880:8880 \ -# -p 6789:6789 \ -# -v $(pwd)/testdata/config:/config \ -# --rm \ -# linuxserver/unifi-controller:LTS +# Local Administrator +# Username: tfacctest +# Password: tfacctest1234 +# Email: tfacctest@example.com -docker run --rm --init \ +docker run --rm --init -d \ -p 8080:8080 \ -p 8443:8443 \ -p 3478:3478/udp \ -p 10001:10001/udp \ -e TZ='America/New_York' \ - -v ~/testdata/unifi:/unifi \ + -v $(pwd)/testdata/unifi:/unifi \ --name unifi \ jacobalberty/unifi:stable + +echo "Waiting for login page..." +timeout 300 bash -c 'while [[ "$(curl --insecure -s -o /dev/null -w "%{http_code}" https://localhost:8443/manage/account/login)" != "200" ]]; do sleep 5; done' +echo "Controller running."