Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RSDK-7007] Add prerelease and other build automation #74

Merged
merged 12 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ on:
pull_request:
workflow_dispatch:
workflow_call:
push:
branches:
- main
release:
types: [created]

jobs:
test:
name: Test lint and build
name: Lint, Test, Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -23,5 +28,31 @@ jobs:
git status
exit 1
fi
- name: Test
run: make test
- name: Build
run: make all

build:
name: Build and Upload
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
needs: test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 #required to be able to generate prerelease tags
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- uses: google-github-actions/setup-gcloud@v2
- name: Build
run: make all
- name: Upload binaries to GCS
run: gsutil -h "Cache-Control:no-cache" cp bin/viam-agent-* gs://packages.viam.com/temp/prerelease/ #TODO use real target after live testing
- name: "Upload install scripts to GCS"
if: github.event_name == 'release'
run: gsutil -h "Cache-Control:no-cache" cp preinstall.sh install.sh uninstall.sh gs://packages.viam.com/temp/prerelease/ #TODO use real target after live testing
Comment on lines +55 to +58
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will edit these to real destinations after some real world testing (e.g. sometime after this merge.) Want to make sure App's discovery isn't going to barf on the new -dev.X syntax in the filenames and break things.

21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ LINUX_ARCH = aarch64
endif

ifeq ($(shell git status -s),)
TAG_VERSION ?= $(shell git tag --points-at | sort -Vr | head -n1 | cut -c2-)
ifeq ($(shell git branch --show-current),main)
LAST_TAG := $(shell git describe --tags --abbrev=0 2>/dev/null)
COMMITS_SINCE_TAG := $(shell git rev-list $(LAST_TAG)..HEAD --count 2>/dev/null)
BASE_VERSION := $(shell echo $(LAST_TAG) | cut -c2-)
NEXT_VERSION := $(shell echo $(BASE_VERSION) | awk -F. '{$$3+=1}1' OFS=.)
ifeq ($(COMMITS_SINCE_TAG),0)
TAG_VERSION ?= $(BASE_VERSION)
else
TAG_VERSION ?= $(NEXT_VERSION)-dev.$(COMMITS_SINCE_TAG)
endif
endif
GIT_REVISION = $(shell git rev-parse HEAD | tr -d '\n')
endif
ifeq ($(TAG_VERSION),)
Expand Down Expand Up @@ -35,7 +45,7 @@ amd64:

bin/viam-agent-$(PATH_VERSION)-$(LINUX_ARCH): go.* *.go */*.go */*/*.go *.service Makefile
go build -o $@ -trimpath -tags $(TAGS) -ldflags $(LDFLAGS) ./cmd/viam-agent/main.go
test "$(PATH_VERSION)" != "custom" && cp $@ bin/viam-agent-stable-$(LINUX_ARCH) || true
echo $(PATH_VERSION) | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$$' && cp $@ bin/viam-agent-stable-$(LINUX_ARCH) || true

.PHONY: clean
clean:
Expand All @@ -49,11 +59,16 @@ lint: bin/golangci-lint
go mod tidy
bin/golangci-lint run -v --fix

.PHONY: test
test:
go test -race ./...

.PHONY: upload-stable
upload-stable: bin/viam-agent-$(PATH_VERSION)-x86_64 bin/viam-agent-$(PATH_VERSION)-aarch64 bin/viam-agent-stable-x86_64 bin/viam-agent-stable-aarch64
test "$(PATH_VERSION)" != "custom"
echo $(PATH_VERSION) | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$$' || exit 1
gsutil -h "Cache-Control:no-cache" cp bin/viam-agent-$(PATH_VERSION)-x86_64 bin/viam-agent-$(PATH_VERSION)-aarch64 bin/viam-agent-stable-x86_64 bin/viam-agent-stable-aarch64 gs://packages.viam.com/apps/viam-agent/

.PHONY: upload-installer
upload-installer:
echo $(PATH_VERSION) | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$$' || exit 1
gsutil -h "Cache-Control:no-cache" cp preinstall.sh install.sh uninstall.sh gs://packages.viam.com/apps/viam-agent/
23 changes: 14 additions & 9 deletions utils/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,21 @@ func TestConvertJson(t *testing.T) {
err := json.Unmarshal([]byte(jsonBytes), newConfig)

testConfig := DefaultConfig()
testConfig.AdditionalNetworks["network1"] = NetworkDefinition{
Type: "wifi",
Interface: "wlan0",
SSID: "foo",
PSK: "bar",
IPv4Address: "192.168.0.1/24",
IPv4Gateway: "192.168.0.255",
IPv4DNS: []string{"192.168.0.255"},
testConfig.AdditionalNetworks = map[string]NetworkDefinition{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test was borked, so fixing now that we run these in automation.

"network1": {
Type: "wifi",
Interface: "wlan0",
SSID: "foo",
PSK: "bar",
IPv4Address: "192.168.0.1/24",
IPv4Gateway: "192.168.0.255",
IPv4DNS: []string{"192.168.0.255"},
},
"network2": {
SSID: "moo",
PSK: "cow",
},
}
testConfig.AdditionalNetworks["network2"] = NetworkDefinition{SSID: "moo", PSK: "cow"}

test.That(t, err, test.ShouldBeNil)
test.That(t, *newConfig, test.ShouldResemble, testConfig)
Expand Down