Skip to content

Commit

Permalink
Development (#4)
Browse files Browse the repository at this point in the history
* Refactored GET

* Implemented PUT and POST

* Minor spelling error

* Fixed import

* Makefile for cross compile

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines
  • Loading branch information
moroen authored Sep 29, 2020
1 parent 25e3b27 commit 5b3329a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 72 deletions.
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
goos=
goarch=amd64
archlabel=x86_64
goarm=
fileext=

deps = ./vendor


default: $(deps)
go build -v

$(deps):
go mod vendor -v

build: $(deps)
env GOOS=$(goos) GOARCH=$(goarch) GOARM=$(goarm) go build -v -o coapcmd-$(goos)-$(archlabel)$(fileext) .

darwin: $(deps)
env GOOS=darwin GOARCH=amd64 go build -v -o coapcmd-darwin-x86_64

linux: $(deps)
env GOOS=linux GOARCH=amd64 go build -v -o coapcmd-linux-x86_64

windows: $(deps)
env GOOS=windows GOARCH=amd64 go build -v -o coapcmd-windows-x86_64.exe
env GOOS=windows GOARCH=386 go build -v -o coapcmd-windows-386.exe

arm: $(deps)
env GOOS=linux GOARCH=arm GOARM=6 go build -v -o coapcmd-linux-armv6 .
env GOOS=linux GOARCH=arm GOARM=7 go build -v -o coapcmd-linux-armv7 .

86 changes: 18 additions & 68 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,81 +9,31 @@ trigger:
pool:
vmImage: 'ubuntu-latest'

variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.11' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
distPath: '$(system.defaultWorkingDirectory)/dist'

strategy:
matrix:
linux_x86_64:
goos: "linux"
goarch: "amd64"
archlabel: "x86_64"
goarm: "7"
fileext: ""
windows_x86_64:
goos: "windows"
goarch: "amd64"
archlabel: "x86_64"
goarm: "7"
fileext: ".exe"
macos_x86_64:
goos: "darwin"
goarch: "amd64"
archlabel: "x86_64"
goarm: "7"
fileext: ""
armv6:
goos: "linux"
goarch: "arm"
archlabel: "armv6"
goarm: "6"
fileext: ""
armv7:
goos: "linux"
goarch: "arm"
archlabel: "armv7"
goarm: "7"
fileext: ""
steps:
- task: GoTool@0
inputs:
version: '1.13.5'

steps:
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
shopt -s dotglob
mv !(gopath) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'
make darwin
displayName: 'Darwin'

- script: |
go version
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
workingDirectory: '$(modulePath)'
displayName: 'Get dependencies'
make linux
displayName: 'Linux'

- script: |
env GOOS=$(goos) GOARCH=$(goarch) GOARM=$(goarm) go build -v -o coapcmd-$(goos)-$(archlabel)$(fileext) .
workingDirectory: '$(modulePath)'
displayName: 'Build'
make windows
displayName: 'Windows'

- script: |
mkdir -p $(distPath)
cp coapcmd* $(distPath)
workingDirectory: '$(modulePath)'
displayName: 'Move artifact'
make arm
displayName: 'Arm'

- task: PublishPipelineArtifact@0
- task: CopyFiles@2
inputs:
Contents: 'coapcmd*'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
artifactName: 'coapcmd-$(goos)-$(archlabel)'
targetPath: '$(distPath)'
displayName: "Publish artifact"
artifactName: coapcmd
4 changes: 0 additions & 4 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ func errorToStatus(err error) string {
return "Unauthorized"
case coap.MethodNotAllowed:
return "MethodNotAllowed"
case coap.ErrorReadTimeout:
return "ReadTimeoutError"
case coap.ErrorWriteTimeout:
return "WriteTimeoutError"
}
return "UnknownStatus"
}
Expand Down
12 changes: 12 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module github.com/moroen/coapcmd

go 1.15

require (
github.com/dustin/go-coap v0.0.0-20190908170653-752e0f79981e // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/moroen/dtls v0.0.0-20200304233939-8868b17f6698 // indirect
github.com/moroen/gocoap v0.5.0
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.7.1
)

0 comments on commit 5b3329a

Please sign in to comment.