Skip to content

Commit

Permalink
Migrate CI to Github actions (zio#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
mijicd authored Dec 31, 2020
1 parent aaf30d6 commit 20f5737
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 149 deletions.
144 changes: 0 additions & 144 deletions .circleci/config.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* @ghostdogpr
.github/workflows/ @softinio @mijicd
build.sbt @softinio @mijicd
project/BuildHelper.scala @softinio @mijicd

19 changes: 19 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name-template: 'v$NEXT_PATCH_VERSION'
tag-template: 'v$NEXT_PATCH_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- title: '🐛 Bug Fixes'
labels:
- 'bug'
- title: '🧰 Maintenance'
labels:
- 'build'
- title: '🌱 Dependency Updates'
labels:
- 'dependency-update'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: |
## Changes
$CHANGES
13 changes: 13 additions & 0 deletions .github/workflows/auto-approve.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Auto approve

on:
pull_request_target

jobs:
auto-approve:
runs-on: ubuntu-20.04
steps:
- uses: hmarr/[email protected]
if: github.actor == 'scala-steward'
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
90 changes: 90 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: CI

on:
pull_request:
branches: ['*']
push:
branches: ['master']
tags: ['v*']

jobs:
lint:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
steps:
- name: Checkout current branch
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v10
- name: Cache scala dependencies
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.sbt
~/.m2
~/.cache
key: sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
- name: Lint code
run: sbt check

test:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
java: ['[email protected]', '[email protected]']
scala: ['2.12.10', '2.13.3']
steps:
- name: Checkout current branch
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v10
with:
java-version: ${{ matrix.java }}
- name: Cache scala dependencies
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.sbt
~/.m2
~/.cache
key: sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
- name: Run tests
run: sbt ++${{ matrix.scala }}! test

publish:
runs-on: ubuntu-20.04
needs: [lint, test]
if: github.event_name != 'pull_request'
steps:
- name: Checkout current branch
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v10
- name: Cache scala dependencies
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.sbt
~/.m2
~/.cache
key: sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
- name: Setup GPG
uses: olafurpg/setup-gpg@v3
- name: Release artifacts
run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
50 changes: 50 additions & 0 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Clean

on: push

jobs:
delete-artifacts:
name: Delete artifacts
runs-on: ubuntu-20.04
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
13 changes: 13 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Release Drafter

on:
push:
branches: ['master']

jobs:
update_release_draft:
runs-on: ubuntu-20.04
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ZIO Connector for AWS SQS

[![CircleCI](https://circleci.com/gh/zio/zio-sqs/tree/master.svg?style=svg)](https://circleci.com/gh/zio/zio-sqs/tree/master)
![CI](https://github.com/zio/zio-sqs/workflows/CI/badge.svg)

This library is a [ZIO](https://github.com/zio/zio)-powered client for AWS SQS. It is built on top of the [AWS SDK for Java 2.0](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/basics.html) via the automatically generated wrappers from [zio-aws](https://github.com/vigoo/zio-aws).

Expand Down
6 changes: 2 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.5")

0 comments on commit 20f5737

Please sign in to comment.