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

Updated svalinn's release pipeline to use travis #117

Merged
merged 2 commits into from
Dec 2, 2019
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
39 changes: 32 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
language: go

go:
- 1.12.x
- 1.13.x
- tip

os:
- linux
- osx

services:
- docker

matrix:
allow_failures:
- go: tip
fast_finish: true

branches:
only:
- master
- /^v[0-9]+\.[0-9]+\.[0-9]+$/

script:
- make style codecov
Expand All @@ -26,5 +22,34 @@ jobs:
include:
- stage: integration
name: "Integration Tests"
if: branch = master
script:
- make it
- stage: tag
name: "Tag For Release"
if: branch = master
before_script:
- echo -e "machine github.com\n login $GH_TOKEN" > ~/.netrc
script:
- export OLD_VERSION=$(make version)
- git config --global user.name "kristinaspring"
- git config --global user.email "kmspring57@gmail.com"
- export TAG=$(cat CHANGELOG.md | perl -0777 -ne 'print "$1" if /.*## \[Unreleased\]\s+## \[(v\d+.\d+.\d+)\].*/s')
- export TODAY=`date +'%m/%d/%Y'`
- export NOTES=$(cat CHANGELOG.md | perl -0777 -ne 'print "$ENV{TODAY}\n\n$1\n" if /.*## \[$ENV{TAG}\]\s(.*?)\s+## \[(v\d+.\d+.\d+)\].*/s')
- if [[ "$TAG" != "" && "$TAG" != "$OLD_VERSION" ]]; then git tag -a "$TAG" -m "$NOTES"; git push origin --tags; echo $?; fi
- stage: release
name: "Make a Release"
if: branch != master
script: skip
before_deploy:
- make release-artifacts
deploy:
on:
all_branches: true
tags: true
provider: releases
api_key: "$GH_TOKEN"
file: ./.ignore/*
skip_cleanup: true

53 changes: 2 additions & 51 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Updated release pipeline to use travis

## [v0.12.1]
- Bumped db package to v0.3.2



## [v0.12.0]
- switched database configuration from postgres to cassandra
- bumped codex-db to v0.2.0



## [v0.11.2]




## [v0.11.0]
- updated urls and imports
- Removed acquirer code and use the bascule acquirer instead
Expand All @@ -30,24 +24,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Updated yaml and documentation
- Added docs folder for more in depth documentation



## [v0.10.2]




## [v0.10.0]
- Store the birthdate and deathdate as Unix with Nanosecond precision.



## [v0.9.1]
- Added deathdate check
- Bumped codex



## [v0.9.0]
- Modified event parsing: if the eventType is state, parse the event
destination to find the device id. Otherwise, take the event Source as the
Expand All @@ -57,19 +42,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Refactored code to separate rules and requestParser into their own packages.
Also moved batchInserter to codex and refactored that.


## [v0.8.0]
- Added ability to turn off max batch size
- Bumped codex to v0.5.0
- Return 429 status code on full queue



## [v0.7.1]
- close request body after reading it



## [v0.7.0]
- Stopped building other services for integ tests
- Added error check for making the request for getting the SAT
Expand All @@ -79,92 +59,63 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added `wrp-go`
- Store the wrp message as Msgpack



## [v0.6.1]
- fixed cipher yaml loading



## [v0.6.0]
- bumped codex to v0.4.0 for cipher upgrades



## [v0.5.1]
- Create timestamp if it doesn't exist in payload
- If request for acquiring SAT for webhook registration receives a non 200, return an error
- Bumped codex-common to v0.3.3



## [v0.5.0]
- Added Blacklist
- Removed pruning
- Fixed shutdown order
- bumped codex to v0.3.2
- bumped webpa-common to v1.0.0


## [v0.4.0]
- adding basic level of encryption
- store event as wrp.Message



## [v0.3.0]
- modified health metric to reflect unhealthy when pinging the database fails
- device IDs are inserted into the db in lowercase



## [v0.2.7]
- replace dep with modules
- bumped codex




## [v0.2.6]
- Bumped codex common
- Converted times to Unix for the `db` package



## [v0.2.5]
- Bumped codex version



## [v0.2.4]
- Bumped codex



## [v0.2.3]
- Limited number of goroutine workers running at one time
- Enabled pprof
- Increased file limit
- Added metrics
- Added batching insertion to database


## [v0.2.2]
Bug Fix: Webhook authorization config loading



## [v0.2.1]
Bug Fix Caduceus config loading




## [v0.2.0]
- added metrics
- fixed signature validation
- Created `webhook` package and created sat and basic token acquirers

- Added unit tests

## [v0.1.1]
Expand All @@ -176,7 +127,7 @@ Bug Fix Caduceus config loading
- Bumped codex version, modified code to match changes

[Unreleased]: https://github.com/xmidt-org/svalinn/compare/v0.12.1...HEAD
[v0.12.1]: https://github.com/xmidt-org/svalinn/compare/v0.12.1-rc.2...v0.12.1
[v0.12.1]: https://github.com/xmidt-org/svalinn/compare/v0.12.0...v0.12.1
[v0.12.0]: https://github.com/xmidt-org/svalinn/compare/v0.11.2...v0.12.0
[v0.11.2]: https://github.com/xmidt-org/svalinn/compare/v0.11.0...v0.11.2
[v0.11.0]: https://github.com/xmidt-org/svalinn/compare/v0.10.2...v0.11.0
Expand Down
17 changes: 0 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ DEFAULT: build
GO ?= go
GOFMT ?= $(GO)fmt
APP := svalinn
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
BINARY := $(FIRST_GOPATH)/bin/$(APP)

PROGVER = $(shell git describe --tags `git rev-list --tags --max-count=1` | tail -1 | sed 's/v\(.*\)/\1/')
RPM_VERSION=$(shell echo $(PROGVER) | sed 's/\(.*\)-\(.*\)/\1/')
RPM_RELEASE=$(shell echo $(PROGVER) | sed -n 's/.*-\(.*\)/\1/p' | grep . && (echo "$(echo $(PROGVER) | sed 's/.*-\(.*\)/\1/')") || echo "1")
BUILDTIME = $(shell date -u '+%Y-%m-%d %H:%M:%S')
GITCOMMIT = $(shell git rev-parse --short HEAD)

Expand All @@ -20,19 +16,6 @@ go-mod-vendor:
build: go-mod-vendor
$(GO) build -o $(APP) -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(PROGVER)"

rpm:
mkdir -p ./.ignore/SOURCES
tar -czvf ./.ignore/SOURCES/$(APP)-$(RPM_VERSION)-$(RPM_RELEASE).tar.gz . --exclude ./.git --exclude ./.ignore --exclude ./conf --exclude ./deploy --exclude ./vendor
cp conf/$(APP).service ./.ignore/SOURCES/
cp conf/$(APP).yaml ./.ignore/SOURCES/
cp LICENSE ./.ignore/SOURCES/
cp NOTICE ./.ignore/SOURCES/
cp CHANGELOG.md ./.ignore/SOURCES/
rpmbuild --define "_topdir $(CURDIR)/.ignore" \
--define "_version $(RPM_VERSION)" \
--define "_release $(RPM_RELEASE)" \
-ba deploy/packaging/$(APP).spec

.PHONY: version
version:
@echo $(PROGVER)
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ make build

The Makefile has the following options you may find helpful:
* `make build`: builds the Svalinn binary
* `make rpm`: builds an rpm containing Svalinn
* `make docker`: builds a docker image for Svalinn, making sure to get all
dependencies
* `make local-docker`: builds a docker image for Svalinn with the assumption
Expand All @@ -205,6 +204,15 @@ The Makefile has the following options you may find helpful:
* `make test`: runs unit tests with coverage for Svalinn
* `make clean`: deletes previously-built binaries and object files

### RPM

First have a local clone of the source and go into the root directory of the
repository. Then use rpkg to build the rpm:
```bash
rpkg srpm --spec <repo location>/<spec file location in repo>
rpkg -C <repo location>/.config/rpkg.conf sources --outdir <repo location>'
```

### Docker

The docker image can be built either with the Makefile or by running a docker
Expand Down
24 changes: 14 additions & 10 deletions deploy/packaging/svalinn.spec
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
%define AutoReqProv: no
%define __os_install_post %{nil}
%define debug_package %{nil}

Name: svalinn
Version: %{_version}
Release: %{_release}%{?dist}
Version: {{{ git_tag_version }}}
Release: 1%{?dist}
Summary: The receiver of data from XMiDT Caduceus.

Vendor: Comcast
Packager: Comcast
Group: System Environment/Daemons
License: ASL 2.0
URL: https://github.com/xmidt-org/svalinn
Source0: %{name}-%{_version}-%{_release}.tar.gz
Source0: %{name}-%{_version}.tar.gz

Prefix: /opt
BuildRoot: %{_tmppath}/%{name}
BuildRequires: systemd
BuildRequires: golang >= 1.11
BuildRequires: git

%description
The shield to protect our users from incoming events for the codex project.
aka. The receiver of data from XMiDT Caduceus

%prep
%setup -q

%build
GO111MODULE=on go build -ldflags "-X 'main.BuildTime=`date -u '+%Y-%m-%d %H:%M:%S'`' -X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=%{_version}" -o $RPM_SOURCE_DIR/%{name} %{_topdir}/..
GO111MODULE=on GOPROXY=https://proxy.golang.org go build -ldflags "-linkmode=external -X 'main.BuildTime=`date -u '+%Y-%m-%d %H:%M:%S'`' -X main.GitCommit={{{ git_short_hash }}} -X main.Version=%{version}" -o %{name} .

%install
echo rm -rf %{buildroot}
%{__install} -d %{buildroot}%{_bindir}
%{__install} -d %{buildroot}%{_initddir}
%{__install} -d %{buildroot}%{_sysconfdir}/%{name}
%{__install} -d %{buildroot}%{_localstatedir}/log/%{name}
%{__install} -d %{buildroot}%{_localstatedir}/log/%{name}˜
%{__install} -d %{buildroot}%{_localstatedir}/run/%{name}
%{__install} -d %{buildroot}%{_unitdir}

%{__install} -p $RPM_SOURCE_DIR/%{name} %{buildroot}%{_bindir}
%{__install} -p $RPM_SOURCE_DIR/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
%{__install} -p $RPM_SOURCE_DIR/%{name}.yaml %{buildroot}%{_sysconfdir}/%{name}/%{name}.yaml
%{__install} -p %{name} %{buildroot}%{_bindir}
%{__install} -p conf/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
%{__install} -p %{name}.yaml %{buildroot}%{_sysconfdir}/%{name}/%{name}.yaml

%files
%defattr(644, root, root, 755)
%doc $RPM_SOURCE_DIR/LICENSE $RPM_SOURCE_DIR/CHANGELOG.md $RPM_SOURCE_DIR/NOTICE
%doc LICENSE CHANGELOG.md NOTICE

%attr(755, root, root) %{_bindir}/%{name}

Expand Down
1 change: 0 additions & 1 deletion release_notes.md

This file was deleted.

19 changes: 19 additions & 0 deletions rpkg.macros
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function git_short_hash {
short_hash="$(cached git_short_hash)"

if [ -z "$short_hash" ]; then
short_hash="$(git rev-parse --short HEAD)"
fi

output "$short_hash"
}

function git_tag_version {
tag="$(cached git_tag_version)"

if [ -z "$tag" ]; then
tag="$(git describe --tags --abbrev=0)"
fi

output "$tag"
}