-
Notifications
You must be signed in to change notification settings - Fork 12
64 lines (63 loc) · 2.05 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Build Compiler image
on:
push:
branches:
- 'main'
pull_request:
branches: [ main ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout github repository
uses: actions/checkout@v2
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: '>=1.17.0'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v0'
- name: Build Compiler image
env:
GOOGLE_SERVICE_ACCOUNT_KEY: ${{ secrets.GCPServiceAccountKey }}
GCR_REPOSITORY: gcr.io/nsx-sm
run: |
set -x
echo $GOOGLE_SERVICE_ACCOUNT_KEY | docker login -u _json_key --password-stdin $GCR_REPOSITORY
git config --global url."https://github.com/".insteadOf "git@github.com:"
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
GITHUB_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha)
fi
if [[ $GITHUB_REF_TYPE == "tag" ]]; then
IMAGE_TAG=$GITHUB_REF_NAME
else
IMAGE_TAG=$GITHUB_SHA
fi
echo "Building compiler image with tag: $IMAGE_TAG"
pushd compiler
make docker.builder
make build_in_container
make docker TAG=$IMAGE_TAG
make publish TAG=$IMAGE_TAG
popd
test:
if: contains(fromJson('["pull_request"]'), github.event_name)
name: Run Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout github repository
uses: actions/checkout@v2
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: '>=1.17.0'
- name: Test Generate Code and Render templates
run: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
pushd compiler
make docker.builder
make test_in_container
make test_render_templates
make test_generate_code_in_container
popd