Skip to content

Commit 1da2cb9

Browse files
committed
feat: Add CI and docs
Signed-off-by: Federico Barcelona <[email protected]>
1 parent 28d1846 commit 1da2cb9

File tree

5 files changed

+1834
-0
lines changed

5 files changed

+1834
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: CI - Pull Request
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build-multiarch:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
include:
15+
- os: darwin
16+
arch: amd64
17+
- os: freebsd
18+
arch: 386
19+
- os: freebsd
20+
arch: amd64
21+
- os: freebsd
22+
arch: arm
23+
- os: linux
24+
arch: 386
25+
- os: linux
26+
arch: amd64
27+
- os: linux
28+
arch: arm
29+
- os: openbsd
30+
arch: 386
31+
- os: openbsd
32+
arch: amd64
33+
- os: solaris
34+
arch: amd64
35+
- os: windows
36+
arch: 386
37+
- os: windows
38+
arch: amd64
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v2
42+
43+
- name: Build project
44+
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o terraform-provider-sysdig
45+
46+
test:
47+
name: Test
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- name: Check out code
52+
uses: actions/checkout@v2
53+
54+
- name: Set up Go
55+
uses: actions/setup-go@v2
56+
with:
57+
go-version: ^1.14
58+
59+
- name: Cache modules
60+
uses: actions/cache@v1
61+
with:
62+
path: ~/go/pkg/mod
63+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
64+
restore-keys: |
65+
${{ runner.os }}-go-
66+
67+
- name: Get dependencies
68+
run: |
69+
go get -u -v github.com/onsi/ginkgo/ginkgo
70+
71+
- name: Test
72+
run: make test
73+
74+
- name: Acceptance tests
75+
run: make testacc
76+
env:
77+
SYSDIG_MONITOR_API_TOKEN: ${{ secrets.KUBELAB_MONITOR_API_TOKEN }}
78+
SYSDIG_SECURE_API_TOKEN: ${{ secrets.KUBELAB_SECURE_API_TOKEN }}
79+
80+
lint:
81+
name: Lint
82+
runs-on: ubuntu-latest
83+
84+
steps:
85+
- name: Check out code
86+
uses: actions/checkout@v2
87+
88+
- name: Lint
89+
continue-on-error: true
90+
uses: golangci/golangci-lint-action@v1
91+
with:
92+
version: v1.27

.github/workflows/docs.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Generate docs
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'website/docs/**'
9+
10+
jobs:
11+
build:
12+
name: Generate web
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
17+
- name: Check out code
18+
uses: actions/checkout@v2
19+
20+
- name: Generate docs from files
21+
run: |
22+
cd docs
23+
./generate.sh > index.md
24+
25+
- name: Commit updated docs
26+
run: |
27+
git config user.email "[email protected]"
28+
git config user.name "Github Actions"
29+
git add docs
30+
31+
git commit -m "docs: Automatic documentation update"
32+
git push origin HEAD:${GITHUB_REF}
33+

.github/workflows/release.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
on:
2+
push:
3+
tags:
4+
- 'v*'
5+
6+
name: Release provider
7+
8+
jobs:
9+
create-release:
10+
name: Create release
11+
runs-on: ubuntu-latest
12+
outputs:
13+
upload_url: ${{ steps.create_release.outputs.upload_url }}
14+
steps:
15+
- name: Create Release
16+
id: create_release
17+
uses: actions/create-release@v1
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
tag_name: ${{ github.ref }}
22+
release_name: ${{ github.ref }}
23+
draft: true
24+
prerelease: false
25+
body: |
26+
### Major Changes
27+
### Minor Changes
28+
### Bug Fixes
29+
30+
build:
31+
name: Build provider
32+
runs-on: ubuntu-latest
33+
needs: [create-release]
34+
strategy:
35+
matrix:
36+
include:
37+
- os: darwin
38+
arch: amd64
39+
- os: freebsd
40+
arch: 386
41+
- os: freebsd
42+
arch: amd64
43+
- os: freebsd
44+
arch: arm
45+
- os: linux
46+
arch: 386
47+
- os: linux
48+
arch: amd64
49+
- os: linux
50+
arch: arm
51+
- os: openbsd
52+
arch: 386
53+
- os: openbsd
54+
arch: amd64
55+
- os: solaris
56+
arch: amd64
57+
- os: windows
58+
arch: 386
59+
- os: windows
60+
arch: amd64
61+
steps:
62+
- name: Checkout code
63+
uses: actions/checkout@v2
64+
65+
- name: Build project
66+
run: |
67+
VERSION=$([ -z "`git tag -l --contains HEAD`" ] && git rev-parse --short HEAD || git tag -l --contains HEAD)
68+
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o terraform-provider-sysdig_$VERSION
69+
tar -czf "terraform-provider-sysdig-${{ matrix.os }}-${{ matrix.arch }}.tar.gz" terraform-provider-sysdig_$VERSION --remove-files
70+
71+
- name: Upload Release Asset
72+
uses: actions/upload-release-asset@v1
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
with:
76+
upload_url: ${{ needs.create-release.outputs.upload_url }}
77+
asset_path: ./terraform-provider-sysdig-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
78+
asset_name: terraform-provider-sysdig-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
79+
asset_content_type: application/tar+gzip

docs/generate.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# set -x # DEBUG
4+
5+
pushd ../website/docs &> /dev/null
6+
7+
cat index.md | sed '1,/---$/d'
8+
9+
printf "\n\n# Data Sources\n\n"
10+
11+
for md in `find ./d -name "*.markdown"`; do
12+
cat "$md" | sed '1,/---$/d' | sed 's/^#/##/g'
13+
printf "\n\n---\n\n"
14+
done
15+
16+
printf "\n\n# Resources\n\n"
17+
18+
for md in `find ./r -name "*.md"`; do
19+
cat "$md" | sed '1,/---$/d' | sed 's/^#/##/g'
20+
printf "\n\n---\n\n"
21+
done
22+
23+
popd &> /dev/null

0 commit comments

Comments
 (0)