-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc4b2c9
commit d7d86ab
Showing
16 changed files
with
1,067 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
stages: | ||
- test | ||
- release | ||
|
||
variables: | ||
BUILD_COMMIT: $CI_COMMIT_SHORT_SHA | ||
BUILD_BRANCH: $CI_COMMIT_REF_NAME | ||
BUILD_BRANCH_SAFE: $CI_COMMIT_REF_SLUG | ||
BUILD_TAG: $CI_COMMIT_TAG | ||
BUILD_NUMBER: $CI_PIPELINE_ID | ||
GITHUB_OWNER: mysteriumnetwork | ||
GITHUB_REPO: payments-smart-contracts | ||
|
||
GO_PACKAGE: github.com/mysteriumnetwork/payments-smart-contracts | ||
GIT_CLONE_PATH: /home/gitlab-runner/go/src/$GO_PACKAGE | ||
GOFLAGS: "-count=1" # Supersedes GOCACHE=off, see: https://github.com/golang/go/issues/29378#issuecomment-449383809 | ||
|
||
after_script: | ||
# docker based jobs leave files owned by root | ||
- sudo chown -R gitlab-runner:gitlab-runner $GOPATH | ||
|
||
e2e: | ||
stage: test | ||
tags: [go] | ||
script: go run mage.go -v e2e | ||
|
||
artifacts: | ||
only: | ||
- tags | ||
stage: release | ||
tags: [go] | ||
script: go run mage.go -v release | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM node:12.16.3 | ||
|
||
WORKDIR /src | ||
ADD . /src | ||
|
||
RUN npm i | ||
RUN npm run compile | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ci | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/magefile/mage/sh" | ||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
// E2e runs the e2e test suite. | ||
func E2e() error { | ||
defer sh.RunV("docker-compose", "down") | ||
err := sh.RunV("docker-compose", "up", "--build", "-d") | ||
if err != nil { | ||
log.Info().Msg("Could not start containers") | ||
return err | ||
} | ||
err = sh.RunV("docker", strings.Split("run --network payments-smart-contracts_default payments-smart-contracts_psc npm run e2e", " ")...) | ||
if err != nil { | ||
log.Info().Msg("Tests failed.") | ||
return err | ||
} | ||
log.Info().Msg("Tests succeeded!") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package ci | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/magefile/mage/mg" | ||
"github.com/magefile/mage/sh" | ||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
func installGhrIfNeeded() error { | ||
err := sh.Run("command", "-v", "ghr") | ||
if err == nil { | ||
return nil | ||
} | ||
log.Info().Msg("ghr not found, will install") | ||
// Ideally, I'd just use a library, but all of them seem to live in the main package, so no import :( | ||
return sh.RunV("go", "get", "-u", "github.com/tcnksm/ghr") | ||
} | ||
|
||
// Release releases the artifacts | ||
func Release() error { | ||
mg.Deps(installGhrIfNeeded) | ||
|
||
tag := os.Getenv("BUILD_TAG") | ||
if tag == "" { | ||
return errors.New("no tag specified") | ||
} | ||
log.Info().Msgf("releasing for TAG: %v", tag) | ||
|
||
defer sh.RunV("docker-compose", "down") | ||
err := sh.RunV("docker-compose", "build", "psc") | ||
if err != nil { | ||
log.Error().Err(err).Msgf("could not build container") | ||
return err | ||
} | ||
|
||
_ = os.Mkdir("./build", os.ModeDir) | ||
o, err := sh.Output("docker", strings.Split("ps -a --filter ancestor=payments-smart-contracts_psc --format {{.ID}}", " ")...) | ||
if err != nil { | ||
log.Error().Err(err).Msgf("could not get container ID") | ||
return err | ||
} | ||
|
||
err = sh.RunV("docker", fmt.Sprintf("cp %v:/src/build/ ./build", strings.TrimSpace(o))) | ||
if err != nil { | ||
log.Error().Err(err).Msgf("could not copy build artifacts") | ||
return err | ||
} | ||
|
||
return sh.RunV("ghr", "-replace", tag, "build/contracts/") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: '3.0' | ||
services: | ||
psc: | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile | ||
depends_on: | ||
- ganache | ||
ganache: | ||
image: trufflesuite/ganache-cli:v6.9.1 | ||
expose: | ||
- 8545 | ||
command: > | ||
--mnemonic "amused glory pen avocado toilet dragon entry kitchen cliff retreat canyon danger" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module github.com/mysteriumnetwork/payments-smart-contracts | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/ethereum/go-ethereum v1.9.14 | ||
github.com/golang/protobuf v1.4.1 // indirect | ||
github.com/magefile/mage v1.9.0 | ||
github.com/mattn/go-colorable v0.1.6 // indirect | ||
github.com/mysteriumnetwork/go-ci v0.0.0-20200415074834-39fc864b0ed4 | ||
github.com/mysteriumnetwork/node v0.0.0-20200514095209-be1b164ff528 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/rs/zerolog v1.17.2 | ||
github.com/tcnksm/ghr v0.13.0 // indirect | ||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120 // indirect | ||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect | ||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect | ||
golang.org/x/sys v0.0.0-20200513112337-417ce2331b5c // indirect | ||
google.golang.org/appengine v1.6.6 // indirect | ||
) |
Oops, something went wrong.