Skip to content

Commit

Permalink
Merge pull request #86 from theiterators/github-actions
Browse files Browse the repository at this point in the history
Adding GitHub Actions initial workflow
  • Loading branch information
pk044 committed Jan 20, 2021
2 parents acef465 + 521f1b9 commit fffead8
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 32 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,44 @@
name: Continuous Integration

on:
push:
branches: ['master']
pull_request:
branches: ['*']
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.12, 2.13.3]
java: [adopt@1.8]
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: Build project
run: sbt ++${{ matrix.scala }} test
52 changes: 52 additions & 0 deletions .github/workflows/clean.yml
@@ -0,0 +1,52 @@
name: Clean

on: push

jobs:
delete-artifacts:
name: Delete Artifacts
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Delete artifacts
run: |
# Customize those three lines with your repository and credentials:
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
# A shortcut to call GitHub API.
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
# A temporary file which receives HTTP response headers.
TMPFILE=/tmp/tmp.$$
# An associative array, key: artifact name, value: number of artifacts of that name.
declare -A ARTCOUNT
# Process all artifacts on this repository, loop on returned "pages".
URL=$REPO/actions/artifacts
while [[ -n "$URL" ]]; do
# Get current page, get response headers in a temporary file.
JSON=$(ghapi --dump-header $TMPFILE "$URL")
# Get URL of next page. Will be empty if we are at the last page.
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
rm -f $TMPFILE
# Number of artifacts on this page:
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))
# Loop on all artifacts on this page.
for ((i=0; $i < $COUNT; i++)); do
# Get name of artifact and count instances of this name.
name=$(jq <<<$JSON -r ".artifacts[$i].name?")
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))
id=$(jq <<<$JSON -r ".artifacts[$i].id?")
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
ghapi -X DELETE $REPO/actions/artifacts/$id
done
done
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion build.sbt
Expand Up @@ -3,12 +3,14 @@ val scala_2_13 = "2.13.3"
val mainScalaVersion = scala_2_13
val supportedScalaVersions = Seq(scala_2_12, scala_2_13)

ThisBuild / crossScalaVersions := supportedScalaVersions
ThisBuild / scalaVersion := mainScalaVersion

lazy val baseSettings = Seq(
organization := "pl.iterators",
organizationName := "Iterators",
organizationHomepage := Some(url("https://iterato.rs")),
homepage := Some(url("https://github.com/theiterators/kebs")),
scalaVersion := mainScalaVersion,
scalacOptions := Seq("-deprecation", "-unchecked", "-feature", "-encoding", "utf8"),
scalafmtVersion := "1.3.0",
scalafmtOnCompile := true
Expand Down

0 comments on commit fffead8

Please sign in to comment.