Skip to content

Commit 2ce8b18

Browse files
committed
🎉 Initiate github actions
* 🎉 Initiate github actions * 💚 Store artifacts * 💚 add timeout * 💚 test release * 💚 Release * 🔥 [patch] * 💚 Trigger only master and pr * 💬 Add github actions badge * 💚 Add permission for circleci * 💚 disable release from circleci
1 parent dbeb733 commit 2ce8b18

File tree

10 files changed

+198
-86
lines changed

10 files changed

+198
-86
lines changed

.circleci/config.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ commands:
3232
sudo tar -C /usr/local -xzf go$GOVERSION.$OS-$ARCH.tar.gz
3333
go version
3434
- run:
35-
name: "Install Dependencies"
35+
name: Install Dependencies
3636
command: |
37+
sudo mkdir -p $GOPATH/bin
38+
sudo chmod -R ugo+rw $GOPATH/bin
39+
3740
make install-dep SUDO="sudo " DEBUG=1
3841
3942
echo 'export GO111MODULE="on"' >> $BASH_ENV
@@ -54,6 +57,7 @@ jobs:
5457
image: ubuntu-1604:201903-01
5558

5659
environment:
60+
CI: true
5761
KUBECONFIG: /tmp/s2h/k3s-kubeconfig
5862
GOPATH: /home/circleci/go
5963
INSTALL_DIR: /home/circleci/go/bin/
@@ -69,12 +73,12 @@ jobs:
6973

7074
# run unit test
7175
- run:
72-
name: "Run Unit Test"
76+
name: Run Unit Test
7377
command: |
7478
make unit-test
7579
7680
- run:
77-
name: "Unit Test Coverage"
81+
name: Unit Test Coverage
7882
command: |
7983
make overall-coverage
8084
@@ -85,7 +89,7 @@ jobs:
8589
8690
# run e2e test
8791
- run:
88-
name: "Run E2E Test"
92+
name: Run E2E Test
8993
command: |
9094
kubectl version
9195
kubectl cluster-info
@@ -95,7 +99,7 @@ jobs:
9599
no_output_timeout: 30m
96100

97101
- run:
98-
name: "E2E Test Coverage"
102+
name: E2E Test Coverage
99103
command: |
100104
make overall-coverage
101105
curl -s https://codecov.io/bash | bash -s - -t $CODECOV_TOKEN
@@ -119,6 +123,7 @@ jobs:
119123
image: ubuntu-1604:201903-01
120124

121125
environment:
126+
CI: true
122127
KUBECONFIG: /tmp/s2h/k3s-kubeconfig
123128
GOPATH: /home/circleci/go
124129
INSTALL_DIR: /home/circleci/go/bin/
@@ -150,7 +155,7 @@ jobs:
150155
151156
- run:
152157
name: Docker logout
153-
when: on_fail
158+
when: always
154159
command: |
155160
make .docker-logout
156161
@@ -159,10 +164,10 @@ workflows:
159164
build-deploy:
160165
jobs:
161166
- build
162-
- release:
163-
requires:
164-
- build
165-
filters:
166-
branches:
167-
only:
168-
- master
167+
# - release:
168+
# requires:
169+
# - build
170+
# filters:
171+
# branches:
172+
# only:
173+
# - master
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Samsahai
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
10+
jobs:
11+
build-test-release:
12+
name: Build & Test & Release
13+
runs-on: ubuntu-16.04
14+
env:
15+
CI: true
16+
KUBECONFIG: /tmp/s2h/k3s-kubeconfig
17+
POD_NAMESPACE: default
18+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
19+
TEST_GIT_USERNAME: ${{ secrets.TEST_GIT_USERNAME }}
20+
TEST_GIT_PASSWORD: ${{ secrets.TEST_GIT_PASSWORD }}
21+
steps:
22+
- name: Checking credentials
23+
run: |
24+
if [ -z "$TEST_GIT_USERNAME" ]; then
25+
echo "No TEST_GIT_USERNAME env variable set"
26+
exit 1
27+
elif [ -z "$TEST_GIT_PASSWORD" ]; then
28+
echo "No TEST_GIT_PASSWORD env variable set"
29+
exit 1
30+
fi
31+
32+
# BUILD
33+
- uses: actions/setup-go@v1
34+
with:
35+
go-version: '1.13.6'
36+
37+
- uses: actions/checkout@v1
38+
with:
39+
fetch-depth: 1
40+
path: go/src/github.com/agoda-com/samsahai
41+
42+
- uses: webfactory/[email protected]
43+
with:
44+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
45+
46+
- name: Prepare ENV
47+
run: |
48+
export GOPATH=/home/runner/work/samsahai/go
49+
echo "::set-env name=GOROOT::$GOROOT"
50+
echo "::set-env name=GOPATH::$GOPATH"
51+
echo "::set-env name=INSTALL_DIR::$GOPATH/bin/"
52+
53+
- uses: actions/cache@v1
54+
with:
55+
path: ~/go/pkg/mod
56+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
57+
restore-keys: |
58+
${{ runner.os }}-go-
59+
60+
- name: Install Dependencies
61+
run: |
62+
sudo mkdir -p $GOPATH/bin
63+
sudo chmod -R ugo+rw $GOPATH/bin
64+
65+
make install-dep SUDO="sudo " DEBUG=1
66+
67+
echo "::set-env name=GO111MODULE::on"
68+
echo "::add-path::/usr/local/kubebuilder/bin:$GOPATH/bin:$GOROOT/bin"
69+
70+
go mod tidy
71+
72+
# TEST
73+
## run unit test
74+
- name: Run Unit Test
75+
if: github.event_name == 'pull_request'
76+
run: |
77+
make unit-test
78+
79+
- name: Unit Test Coverage
80+
if: github.event_name == 'pull_request'
81+
run: |
82+
make overall-coverage
83+
84+
## run e2e test
85+
- name: Prepare E2E Test Environment
86+
if: github.event_name == 'pull_request'
87+
run: |
88+
make prepare-env-e2e-k3d
89+
90+
- name: Run E2E Test
91+
if: github.event_name == 'pull_request'
92+
run: |
93+
kubectl version
94+
kubectl cluster-info
95+
helm version
96+
97+
make e2e-test-k3d DEBUG=1
98+
timeout-minutes: 30
99+
100+
- name: E2E Test Coverage
101+
if: github.event_name == 'pull_request'
102+
run: |
103+
make overall-coverage
104+
curl -s https://codecov.io/bash | bash -s - -t $CODECOV_TOKEN
105+
106+
- name: Save test results
107+
if: always() && github.event_name == 'pull_request'
108+
run: |
109+
mkdir -p ./test/result/
110+
find . -type f -regex "./.*unit-test.xml" -exec cp {} ./test/result/ \;
111+
ls -al ./test/result/
112+
113+
- name: Store artifacts
114+
if: always() && github.event_name == 'pull_request'
115+
uses: actions/upload-artifact@v1
116+
with:
117+
name: test-result
118+
path: ./test/result
119+
120+
# RELEASE
121+
- name: Release
122+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.TEST_GIT_PASSWORD }}
125+
GITHUB_REPO: agoda-com/samsahai
126+
DOCKER_USER: ${{ secrets.QUAY_DOCKER_USER }}
127+
DOCKER_PASSWORD: ${{ secrets.QUAY_DOCKER_TOKEN }}
128+
run: |
129+
export INSTALL_DIR="$(pwd)/bin/"
130+
131+
git config --global url."ssh://[email protected]".insteadOf "https://github.com" || true
132+
git config --global gc.auto 0 || true
133+
134+
ls -al
135+
rm -rf tmp
136+
make auto-release SUDO="sudo "
137+
138+
- name: Docker logout
139+
if: always()
140+
run: |
141+
make .docker-logout

.goreleaser.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ checksum:
3535
dist: out
3636
#release:
3737
# disable: true
38+
3839
changelog:
3940
sort: asc
4041
filters:

0 commit comments

Comments
 (0)