-
Notifications
You must be signed in to change notification settings - Fork 5
150 lines (136 loc) · 4.95 KB
/
component-go.yaml
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
name: Component / Go
on:
push:
branches: ["main"]
paths:
- '.github/workflows/component-go.yaml'
- 'component/**'
- 'examples/component/**'
pull_request:
branches: ["main"]
paths:
- '.github/workflows/component-go.yaml'
- 'component/**'
- 'examples/component/**'
env:
TINYGO_VERSION: "0.33.0"
GOLANGCI_VERSION: "v1.61"
WASH_VERSION: "0.37.0"
WASM_TOOLS_VERSION: "1.220.0"
permissions:
contents: read
defaults:
run:
working-directory: ./component
jobs:
lint:
# Context: https://github.com/golangci/golangci-lint-action/blob/v6.1.1/README.md#annotations
permissions:
# Required: allow read access to the content for analysis.
contents: read
# Optional: allow write access to checks to allow the action to annotate code in the PR.
checks: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
version: ${{ env.GOLANGCI_VERSION }}
working-directory: ./component
- uses: taiki-e/install-action@acd25891978b4cdaebd139d3efef606d26513b14 # v2.47.0
with:
tool: ${{ format('wasm-tools@{0}', env.WASM_TOOLS_VERSION) }}
- name: Go generate
run: |
go generate ./...
if ! test -z "$(git status --porcelain)"; then
echo "Go generate modified files. Please run go generate and commit the changes."
git status
exit 1
fi
sdk-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: "./component/go.mod"
- uses: acifani/setup-tinygo@b2ba42b249c7d3efdfe94166ec0f48b3191404f7 # v2.0.0
with:
tinygo-version: ${{ env.TINYGO_VERSION }}
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
examples:
# Context: https://github.com/golangci/golangci-lint-action/blob/v6.1.1/README.md#annotations
permissions:
# Required: allow read access to the content for analysis.
contents: read
# Optional: allow write access to checks to allow the action to annotate code in the PR.
checks: write
strategy:
fail-fast: false
matrix:
example:
- http-server
- http-client
- http-password-checker
- invoke
- sqldb-postgres-query
tinygo-version:
- "0.33.0"
- "0.34.0"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: "./examples/component/${{ matrix.example }}/go.mod"
- uses: acifani/setup-tinygo@b2ba42b249c7d3efdfe94166ec0f48b3191404f7 # v2.0.0
with:
tinygo-version: ${{ matrix.tinygo-version }}
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
version: ${{ env.GOLANGCI_VERSION }}
working-directory: "./examples/component/${{ matrix.example }}"
- uses: taiki-e/install-action@acd25891978b4cdaebd139d3efef606d26513b14 # v2.47.0
with:
tool: ${{ format('wash@{0},wasm-tools@{1}', env.WASH_VERSION, env.WASM_TOOLS_VERSION) }}
- name: Go generate
run: |
go generate ./...
if ! test -z "$(git status --porcelain)"; then
echo "Go generate modified files. Please run go generate and commit the changes."
git status
exit 1
fi
- name: wash build
working-directory: "./examples/component/${{ matrix.example }}"
run: |
wash build
- name: run tests
working-directory: "./examples/component/${{ matrix.example }}"
run: go test ./...
# Run the wadm file and make sure it deploys
- name: test component load
shell: bash
working-directory: "./examples/component/${{ matrix.example }}"
# TODO: Add a test to the matrix for testing the running component (i.e. with `curl` or `wash call`)
run: |
set -xe
wash up -d --wadm-manifest wadm.yaml;
sleep 1;
TRIES=0
while [[ $(wash get inventory --output=json | jq '.inventories[0].components | length') -eq 0 ]] ; do
if [[ $TRIES -gt 10 ]]; then
echo "❌ failed to find component in inventory output after deploying example manifest";
exit -1;
fi
TRIES=$((TRIES+1));
sleep 1;
done;
echo "✅ successfully started at least one component";
wash app delete wadm.yaml;
wash down --all;
exit 0;