未验证 提交 97a4dd8c 编写于 作者: D Dejan Mijić 提交者: GitHub

Migrate to GitHub actions (#258)

上级 5900c4c7
version: 2.1
scala_212: &scala_212
SCALA_VERSION: 2.12.11
scala_213: &scala_213
SCALA_VERSION: 2.13.3
jdk_8: &jdk_8
JDK_VERSION: 8
jdk_11: &jdk_11
JDK_VERSION: 11
machine_ubuntu: &machine_ubuntu
machine:
image: ubuntu-1604:201903-01
install_deps: &install_jdk
- run:
name: Install JDK
command: |
while $(ps aux | grep -i ' apt ' | grep -v grep > /dev/null); do sleep 1; done # Wait for apt to be ready
sudo rm /etc/apt/sources.list.d/*
sudo tee /etc/apt/sources.list > /dev/null \<< 'EOF'
deb http://mirror.math.princeton.edu/pub/ubuntu/ xenial main universe
deb http://mirror.math.princeton.edu/pub/ubuntu/ xenial-updates main universe
deb http://mirror.math.princeton.edu/pub/ubuntu/ xenial-backports main universe
deb http://mirror.math.princeton.edu/pub/ubuntu/ xenial-security main restricted universe
EOF
if [ $JDK_VERSION == 11 ]; then
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ -y
fi
sudo apt update
if [ $JDK_VERSION == 11 ]; then
sudo apt install -y adoptopenjdk-11-hotspot
elif [ $JDK_VERSION == 8 ]; then
sudo apt install -y openjdk-8-jdk
fi
java -version
load_cache: &load_cache
- restore_cache:
key: sbt-zio-redis-cache
clean_cache: &clean_cache
- run:
name: Clean unwanted files from cache
command: |
rm -fv $HOME/.ivy2/.sbt.ivy.lock
find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete
find $HOME/.sbt -name "*.lock" -print -delete
save_cache: &save_cache
- save_cache:
key: sbt-zio-redis-cache
paths:
- "~/.ivy2/cache"
- "~/.sbt"
- "~/.m2"
- "~/.cache"
filter_tags: &filter_tags
tags:
only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
lint: &lint
steps:
- checkout
- <<: *load_cache
- run:
name: Lint code
command: ./sbt ++${SCALA_VERSION}! fmtCheck fixCheck
- <<: *save_cache
testJVM: &testJVM
steps:
- checkout
- <<: *load_cache
- <<: *install_jdk
- run:
name: Run Redis
command: docker-compose up
background: true
- run:
name: Run tests
command: ./sbt ++${SCALA_VERSION}! test
- <<: *save_cache
release: &release
steps:
- checkout
- run:
name: Fetch git tags
command: git fetch --tags
- <<: *load_cache
- run:
name: Write sonatype credentials
command: echo "credentials += Credentials(\"Sonatype Nexus Repository Manager\", \"oss.sonatype.org\", \"${SONATYPE_USER}\", \"${SONATYPE_PASSWORD}\")" > ~/.sbt/1.0/sonatype.sbt
- run:
name: Write PGP public key
command: echo -n "${PGP_PUBLIC}" | base64 -di > /tmp/public.asc
- run:
name: Write PGP secret key
command: echo -n "${PGP_SECRET}" | base64 -di > /tmp/secret.asc
- run:
name: Release artifacts
command: ./sbt ++${SCALA_VERSION}! ci-release
jobs:
lint:
<<: *lint
<<: *machine_ubuntu
environment:
- <<: *scala_213
- <<: *jdk_8
test_212_jdk8:
<<: *testJVM
<<: *machine_ubuntu
environment:
- <<: *scala_212
- <<: *jdk_8
test_213_jdk8:
<<: *testJVM
<<: *machine_ubuntu
environment:
- <<: *scala_213
- <<: *jdk_8
test_212_jdk11:
<<: *testJVM
<<: *machine_ubuntu
environment:
- <<: *scala_212
- <<: *jdk_11
test_213_jdk11:
<<: *testJVM
<<: *machine_ubuntu
environment:
- <<: *scala_213
- <<: *jdk_11
release:
<<: *release
<<: *machine_ubuntu
environment:
- <<: *scala_213
- <<: *jdk_8
workflows:
version: 2
build:
jobs:
- lint:
filters:
<<: *filter_tags
- test_212_jdk8:
requires:
- lint
filters:
<<: *filter_tags
- test_213_jdk8:
requires:
- lint
filters:
<<: *filter_tags
- test_212_jdk11:
requires:
- lint
filters:
<<: *filter_tags
- test_213_jdk11:
requires:
- lint
filters:
<<: *filter_tags
- release:
context: Sonatype2
requires:
- test_212_jdk8
- test_213_jdk8
- test_212_jdk11
- test_213_jdk11
filters:
<<: *filter_tags
branches:
ignore: /.*/
* @zio/zio-redis
.github/workflows/ @softinio @mijicd
build.sbt @softinio @mijicd
project/BuildHelper.scala @softinio @mijicd
name: CI
on:
pull_request:
branches: ['*']
push:
branches: ['master']
tags: ['v*']
jobs:
lint:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
java: ['adopt@1.8', 'adopt@1.11']
scala: ['2.12.12', '2.13.3']
steps:
- name: Checkout current branch
uses: actions/checkout@v2.3.4
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: Lint code
run: sbt ++${{ matrix.scala }}! fmtCheck fixCheck
test:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
java: ['adopt@1.8', 'adopt@1.11']
scala: ['2.12.12', '2.13.3']
steps:
- name: Checkout current branch
uses: actions/checkout@v2.3.4
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 test containers
run: docker-compose up -d
- 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/checkout@v2.3.4
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 }}
name: Clean
on: push
jobs:
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
# ZIO Redis
| CI | Discord |
|------------------------------------------|-------------------------------------------|
| [![CircleCI][Badge-Circle]][Link-Circle] | [![Discord][Badge-Discord]][Link-Discord] |
| CI | Discord |
|------------------|-------------------------------------------|
| [![CI][Badge-CI] | [![Discord][Badge-Discord]][Link-Discord] |
ZIO-based Redis client.
> The client is still a work-in-progress. Watch this space!
[Badge-Circle]: https://circleci.com/gh/zio/zio-redis/tree/master.svg?style=svg
[Badge-CI]: https://github.com/zio/zio-redis/workflows/CI/badge.svg
[Badge-Discord]: https://img.shields.io/discord/629491597070827530?logo=discord
[Link-Circle]: https://circleci.com/gh/zio/zio-redis/tree/master
[Link-Discord]: https://discord.gg/2ccFBr4
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册