Skip to content

Commit 09864f0

Browse files
Merge pull request #44 from brbrown25/feature/ISSUE-38
feat(github actions): adding in github actions for ci instead of trav…
2 parents 7e8eb26 + db2638c commit 09864f0

File tree

4 files changed

+137
-1
lines changed

4 files changed

+137
-1
lines changed

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# This file was automatically generated by sbt-github-actions using the
2+
# githubWorkflowGenerate task. You should add and commit this file to
3+
# your git repository. It goes without saying that you shouldn't edit
4+
# this file by hand! Instead, if you wish to make changes, you should
5+
# change your sbt build configuration to revise the workflow description
6+
# to meet your needs, then regenerate this file.
7+
8+
name: Continuous Integration
9+
10+
on:
11+
pull_request:
12+
branches: ['*']
13+
push:
14+
branches: ['*']
15+
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
19+
jobs:
20+
build:
21+
name: Build and Test
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest]
25+
scala: [2.12.2]
26+
java:
27+
28+
29+
30+
runs-on: ${{ matrix.os }}
31+
steps:
32+
- name: Checkout current branch (full)
33+
uses: actions/checkout@v2
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Setup Java and Scala
38+
uses: olafurpg/setup-scala@v10
39+
with:
40+
java-version: ${{ matrix.java }}
41+
42+
- name: Cache sbt
43+
uses: actions/cache@v2
44+
with:
45+
path: |
46+
~/.sbt
47+
~/.ivy2/cache
48+
~/.coursier/cache/v1
49+
~/.cache/coursier/v1
50+
~/AppData/Local/Coursier/Cache/v1
51+
~/Library/Caches/Coursier/v1
52+
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
53+
54+
- name: Check that workflows are up to date
55+
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
56+
57+
- name: Build project
58+
run: sbt ++${{ matrix.scala }} test
59+
60+
- run: pushd target/sbt-test/dotty-template/scripted
61+
62+
- run: sbt run test
63+
64+
- run: popd

.github/workflows/clean.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This file was automatically generated by sbt-github-actions using the
2+
# githubWorkflowGenerate task. You should add and commit this file to
3+
# your git repository. It goes without saying that you shouldn't edit
4+
# this file by hand! Instead, if you wish to make changes, you should
5+
# change your sbt build configuration to revise the workflow description
6+
# to meet your needs, then regenerate this file.
7+
8+
name: Clean
9+
10+
on: push
11+
12+
jobs:
13+
delete-artifacts:
14+
name: Delete Artifacts
15+
runs-on: ubuntu-latest
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
steps:
19+
- name: Delete artifacts
20+
run: |
21+
# Customize those three lines with your repository and credentials:
22+
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
23+
24+
# A shortcut to call GitHub API.
25+
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
26+
27+
# A temporary file which receives HTTP response headers.
28+
TMPFILE=/tmp/tmp.$$
29+
30+
# An associative array, key: artifact name, value: number of artifacts of that name.
31+
declare -A ARTCOUNT
32+
33+
# Process all artifacts on this repository, loop on returned "pages".
34+
URL=$REPO/actions/artifacts
35+
while [[ -n "$URL" ]]; do
36+
37+
# Get current page, get response headers in a temporary file.
38+
JSON=$(ghapi --dump-header $TMPFILE "$URL")
39+
40+
# Get URL of next page. Will be empty if we are at the last page.
41+
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
42+
rm -f $TMPFILE
43+
44+
# Number of artifacts on this page:
45+
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))
46+
47+
# Loop on all artifacts on this page.
48+
for ((i=0; $i < $COUNT; i++)); do
49+
50+
# Get name of artifact and count instances of this name.
51+
name=$(jq <<<$JSON -r ".artifacts[$i].name?")
52+
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))
53+
54+
id=$(jq <<<$JSON -r ".artifacts[$i].id?")
55+
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
56+
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
57+
ghapi -X DELETE $REPO/actions/artifacts/$id
58+
done
59+
done

build.sbt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This build is for this Giter8 template.
22
// To test the template run `g8` or `g8Test` from the sbt session.
33
// See http://www.foundweekends.org/giter8/testing.html#Using+the+Giter8Plugin for more details.
4+
lazy val scalaVersions = Seq("2.12.2")
45
lazy val root = project
56
.in(file("."))
67
.settings(
@@ -9,5 +10,16 @@ lazy val root = project
910
val _ = (g8Test in Test).toTask("").value
1011
},
1112
scriptedLaunchOpts ++= List("-Xms1024m", "-Xmx1024m", "-XX:ReservedCodeCacheSize=128m", "-XX:MaxPermSize=256m", "-Xss2m", "-Dfile.encoding=UTF-8"),
12-
resolvers += Resolver.url("typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/"))(Resolver.ivyStylePatterns)
13+
resolvers += Resolver.url("typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/"))(Resolver.ivyStylePatterns),
14+
crossScalaVersions := scalaVersions
1315
)
16+
17+
ThisBuild / githubWorkflowJavaVersions := Seq("[email protected]", "[email protected]", "[email protected]")
18+
ThisBuild / githubWorkflowScalaVersions := scalaVersions
19+
ThisBuild / githubWorkflowBuildPostamble := Seq(
20+
WorkflowStep.Run(List("pushd target/sbt-test/dotty-template/scripted")),
21+
WorkflowStep.Run(List("sbt run test")),
22+
WorkflowStep.Run(List("popd"))
23+
)
24+
ThisBuild / githubWorkflowPublishTargetBranches := Nil
25+
Global / onChangedBuildSource := ReloadOnSourceChanges

project/giter8.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1")
2+
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.1")

0 commit comments

Comments
 (0)