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

Migrate CI to GA #710

Merged
merged 23 commits into from
Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f103ae6
add sbt-github-actions plugin, upgrade sbt to 1.4.5;
greenhat Dec 22, 2020
b0fd69a
fix crossScalaVersions;
greenhat Dec 22, 2020
1e8a324
restore crossScalaVersions for all projects;
greenhat Dec 22, 2020
f4632e3
remove sbt-github-actions plugin;
greenhat Dec 22, 2020
e45bef7
remove clean.yml;
greenhat Dec 22, 2020
7fc21eb
add tags to ignore (starting with "v");
greenhat Dec 22, 2020
69d4fa7
combine coverage report generation with test run;
greenhat Dec 22, 2020
fe365f6
remove tags-ignore;
greenhat Dec 22, 2020
3e85334
remove snapshot publishing on Travis;
greenhat Dec 22, 2020
4dcd8e3
add COVERALLS_REPO_TOKEN env var;
greenhat Dec 22, 2020
428a5e6
switch from sbt-git to sbt-dynver for 'version';
greenhat Dec 22, 2020
27e659b
add release.yml workflow;
greenhat Dec 22, 2020
69822e8
rename main GA workflow to CI;
greenhat Dec 22, 2020
a99868b
run coverageReport under matrix scala version;
greenhat Dec 22, 2020
8e3fd3e
remove .travis.yml;
greenhat Dec 22, 2020
799dc11
switch to codecov;
greenhat Dec 23, 2020
0854f14
add cache to release.yml workflow;
greenhat Dec 23, 2020
b193d08
fix import_gpg.sh permissions, add java version to release.yml;
greenhat Dec 23, 2020
567bcf8
add required SCM url be Sonatype;
greenhat Dec 23, 2020
7893f98
add CONTRIBUTING.md with instructions on how to make a release;
greenhat Dec 23, 2020
e8cac37
update sbt-sonatype plugin;
greenhat Dec 23, 2020
f5d4c03
fix release.yml step name;
greenhat Dec 23, 2020
519215b
delete .travis.jvmopts;
greenhat Dec 23, 2020
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
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
branches:
- master
- develop
pull_request:
types:
- opened
- synchronize

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
name: Test and publish a snapshot
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.10, 2.11.12]
java: [adopt@1.11]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
with:
java-version: ${{ matrix.java }}

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Runs tests and collect coverage
run: sbt -jvm-opts ci/ci.jvmopts ++${{ matrix.scala }} coverage test coverageReport coverageAggregate

# - name: Upload coverage report
# run: sbt ++${{ matrix.scala }} coverageReport coverageAggregate coveralls
# env:
# COVERALLS_REPO_TOKEN: $${{ secrets.COVERALLS_REPO_TOKEN }}

- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true

- name: Publish a snapshot ${{ github.ref }}
run: sbt ++${{ matrix.scala }} publish
env:
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish a release

on:
release:
types: [published]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
publish_release:
name: Publish release to Sonatype
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
with:
java-version: adopt@1.11

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Import GPG key
run: ci/import_gpg.sh
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}

- name: Publish release ${{ github.ref }}
run: sbt +publishSigned sonatypeBundleRelease
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ spam-tests/
.bloop/
.metals/
.vscode/
project/metals.sbt
project/metals.sbt
/project/project/
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Releasing
To publish release version to Sonatype, do the following:
- make a tag with version number `vX.Y.Z` (used by `sbt-dynver` to set `version` in `build.sbt`);
- use the new tag to make a Github release, which triggers [`release.yml`](.github/workflows/release.yml) workflow and publishes release version to Sonatype;
42 changes: 11 additions & 31 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -43,39 +43,19 @@ lazy val commonSettings = Seq(
</developer>
</developers>,
publishMavenStyle := true,
publishTo := sonatypePublishToBundle.value
publishTo := sonatypePublishToBundle.value,
scmInfo := Some(
ScmInfo(
url("https://github.com/ScorexFoundation/sigmastate-interpreter"),
"scm:git@github.com:ScorexFoundation/sigmastate-interpreter.git"
)
),
)

enablePlugins(GitVersioning)

version in ThisBuild := {
if (git.gitCurrentTags.value.nonEmpty) {
git.gitDescribedVersion.value.get
} else {
if (git.gitHeadCommit.value.contains(git.gitCurrentBranch.value)) {
// see https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
if (Try(sys.env("TRAVIS")).getOrElse("false") == "true") {
// pull request number, "false" if not a pull request
if (Try(sys.env("TRAVIS_PULL_REQUEST")).getOrElse("false") != "false") {
// build is triggered by a pull request
val prBranchName = Try(sys.env("TRAVIS_PULL_REQUEST_BRANCH")).get
val prHeadCommitSha = Try(sys.env("TRAVIS_PULL_REQUEST_SHA")).get
prBranchName + "-" + prHeadCommitSha.take(8) + "-SNAPSHOT"
} else {
// build is triggered by a push
val branchName = Try(sys.env("TRAVIS_BRANCH")).get
branchName + "-" + git.gitHeadCommit.value.get.take(8) + "-SNAPSHOT"
}
} else {
git.gitHeadCommit.value.get.take(8) + "-SNAPSHOT"
}
} else {
git.gitCurrentBranch.value + "-" + git.gitHeadCommit.value.get.take(8) + "-SNAPSHOT"
}
}
}

git.gitUncommittedChanges in ThisBuild := true
// prefix version with "-SNAPSHOT" for builds without a git tag
dynverSonatypeSnapshots in ThisBuild := true
// use "-" instead of default "+"
dynverSeparator in ThisBuild := "-"

val bouncycastleBcprov = "org.bouncycastle" % "bcprov-jdk15on" % "1.64"
val scrypto = "org.scorexfoundation" %% "scrypto" % "2.1.10"
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions ci/import_gpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# setting up gpg2 for reading passphrase from parameters
# via https://github.com/beautiful-scala/scalastyle/blob/master/.github/workflows/release.yml#L16
# from https://github.com/olafurpg/sbt-ci-release/issues/95

# setup gpg
mkdir ~/.gnupg && chmod 700 ~/.gnupg
echo use-agent >> ~/.gnupg/gpg.conf
echo pinentry-mode loopback >> ~/.gnupg/gpg.conf
echo allow-loopback-pinentry >> ~/.gnupg/gpg-agent.conf
chmod 600 ~/.gnupg/*
echo RELOADAGENT | gpg-connect-agent

# decode key
# private key should be previously exported with:
# gpg --export-secret-keys [id] | base64 | pbcopy
# and stored as github repository secret under the following name (see env var name below)
printf "$GPG_SIGNING_KEY" | base64 --decode > ~/.gnupg/private.key

# import key
gpg --no-tty --batch --yes --import ~/.gnupg/private.key
30 changes: 0 additions & 30 deletions ci/pubring.asc

This file was deleted.

Binary file removed ci/secring.asc.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.7
sbt.version=1.4.5
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ logLevel := Level.Warn

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")