-
-
Notifications
You must be signed in to change notification settings - Fork 18
168 lines (136 loc) · 4.54 KB
/
build-test.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Build & tests
on:
push:
branches:
- "**"
- "!main"
tags:
- "v*.*.*"
jobs:
test:
runs-on: ubuntu-latest
if: " ! startsWith(github.event.ref, 'refs/tags/v')"
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: novops
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ runner.arch }}-cargo
- uses: actions/cache@v3
with:
path: |
~/.local/share/containers/storage/
key: ${{ runner.os }}-${{ runner.arch }}-podman
- run: nix develop -c make test
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: novops
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- uses: actions/cache@v3
with:
path: |
build/cache
key: ${{ runner.os }}-${{ runner.arch }}-podman
- run: nix develop -c make build-image build-binary
- name: Upload built artifacts
uses: actions/upload-artifact@v3
with:
name: novops-build
if-no-files-found: error
path: |
build/novops
build/novops.zip
build/novops.zip.sha256sum
build/image.tar
# Build and push to cachix
build-flake:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: novops
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build --json | jq -r '.[].outputs | to_entries[].value' | cachix push novops
# Some end-user CLI test
# Which cannot be tested easily with unit tests
test-novops-cli:
runs-on: ubuntu-latest
if: " ! startsWith(github.event.ref, 'refs/tags/v')"
needs: build
steps:
- uses: actions/checkout@v3
- name: download novops artifacts
uses: actions/download-artifact@v3
with:
name: novops-build
path: build
- name: novops load
run: |
ls -al build
chmod +x build/novops
build/novops load -c tests/.novops.plain-strings.yml -s .envrc -e dev
cat .envrc >> "$GITHUB_ENV"
- name: check novops loaded values
run: env | grep MY_APP_HOST
- name: novops run and check var
run: |
build/novops run -c tests/.novops.plain-strings.yml -e dev -- sh -c "env | grep DOG_PATH"
- name: novops run with builtin env variables
run: |
export NOVOPS_CONFIG=tests/.novops.plain-strings.yml
export NOVOPS_ENVIRONMENT=dev
build/novops run -- sh -c "env | grep DOG_PATH"
- name: novops list environments
run: |
build/novops list environments -c tests/.novops.multi-env.yml | grep preprod
# json format should return "preprod" with quotes
build/novops list environments -c tests/.novops.multi-env.yml -o json | grep '"preprod"'
- name: novops list outputs
run: |
build/novops list outputs -e dev -c tests/.novops.multi-env.yml | grep MY_APP_HOST
build/novops list outputs -e dev -c tests/.novops.multi-env.yml -o json | grep '"MY_APP_HOST"'
# Upload artifacts for release tags only
release-artifacts:
needs: build
permissions:
contents: write
pull-requests: write
if: startsWith(github.event.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: download novops artifacts
uses: actions/download-artifact@v3
with:
name: novops-build
path: build
- run: nix develop -c make docker-publish
- run: nix develop -c make release-artifacts
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}