[DEV-12317] test and build workflow
This commit is contained in:
parent
d6a68c97dc
commit
f362df276b
1 changed files with 156 additions and 17 deletions
173
.github/workflows/build-and-publish.yml
vendored
173
.github/workflows/build-and-publish.yml
vendored
|
|
@ -1,25 +1,164 @@
|
||||||
name: Clojure CI
|
name: Test and Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [ master ]
|
||||||
- master
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
deps:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions: write-all
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v3
|
||||||
- name: Install dependencies
|
with:
|
||||||
run: lein deps
|
ref: ${{ github.head_ref }}
|
||||||
- name: Start mongo
|
- name: Cache Dependencies
|
||||||
run: sudo docker run --rm -d -p 27017:27017 mongo
|
uses: actions/cache@v3
|
||||||
- name: Run tests
|
|
||||||
run: lein test
|
|
||||||
- name: Publish
|
|
||||||
env:
|
env:
|
||||||
CLOJARS_USER: ${{ secrets.CLOJARS_USER }}
|
cache-name: artifacts
|
||||||
CLOJARS_PASS: ${{ secrets.CLOJARS_PASS }}
|
with:
|
||||||
run: lein deploy clojars
|
path: ~/.m2
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./project.clj') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-build-
|
||||||
|
${{ runner.os }}-
|
||||||
|
- name: Prepare java
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: 17
|
||||||
|
- name: Install clojure tools
|
||||||
|
uses: DeLaGuardo/setup-clojure@3.2
|
||||||
|
with:
|
||||||
|
lein: 2.10.0
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: lein deps
|
||||||
|
format:
|
||||||
|
needs: deps
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
- name: Cache Dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: artifacts
|
||||||
|
with:
|
||||||
|
path: ~/.m2
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./project.clj') }}
|
||||||
|
- name: Check Format
|
||||||
|
run: lein cljfmt check
|
||||||
|
linter:
|
||||||
|
needs: deps
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
- name: Cache Dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: artifacts
|
||||||
|
with:
|
||||||
|
path: ~/.m2
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./project.clj') }}
|
||||||
|
- name: Look for Lint
|
||||||
|
run: lein kibit
|
||||||
|
test:
|
||||||
|
needs: deps
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
mongo:
|
||||||
|
image: mongo
|
||||||
|
options:
|
||||||
|
--health-cmd "echo 'db.runCommand("ping").ok' | mongosh --quiet"
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 3
|
||||||
|
ports:
|
||||||
|
- 27017:27017
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
- name: Cache Dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: artifacts
|
||||||
|
with:
|
||||||
|
path: ~/.m2
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./project.clj') }}
|
||||||
|
- name: Run Unit Tests
|
||||||
|
run: lein test
|
||||||
|
build:
|
||||||
|
needs: test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions: write-all
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
- name: Cache Dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: artifacts
|
||||||
|
with:
|
||||||
|
path: ~/.m2
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./project.clj') }}
|
||||||
|
- name: Jar and Push to Repository
|
||||||
|
run: lein deploy github
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
notify_success:
|
||||||
|
needs: [format, linter, test, build]
|
||||||
|
if: ${{ success() }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
- name: Project Version
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
version=$(sed -n 's/^.*defproject.* //p' project.clj)
|
||||||
|
echo "::set-output name=value::$version"
|
||||||
|
- name: Success Notification
|
||||||
|
uses: rtCamp/action-slack-notify@v2
|
||||||
|
env:
|
||||||
|
SLACK_WEBHOOK: ${{ secrets.AVAIL_TEAM_SLACK_WEBHOOK }}
|
||||||
|
SLACK_USERNAME: 'Availability Wizard'
|
||||||
|
SLACK_ICON_EMOJI: ':partywizard:'
|
||||||
|
SLACK_TITLE: ${{ github.repository }}
|
||||||
|
MSG_MINIMAL: actions url,commit
|
||||||
|
SLACK_MESSAGE: |
|
||||||
|
${{ github.workflow }} for ${{ github.ref }} was a success :sunny:
|
||||||
|
|
||||||
|
VERSION: ${{ steps.version.outputs.value }}
|
||||||
|
notify_failure:
|
||||||
|
needs: [format, linter, test, build]
|
||||||
|
if: ${{ failure() }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
- name: Failure Notification
|
||||||
|
uses: rtCamp/action-slack-notify@v2
|
||||||
|
env:
|
||||||
|
SLACK_WEBHOOK: ${{ secrets.AVAIL_TEAM_SLACK_WEBHOOK }}
|
||||||
|
SLACK_COLOR: '#FF0000'
|
||||||
|
SLACK_USERNAME: 'Availability Wizard'
|
||||||
|
SLACK_ICON_EMOJI: ':partywizard:'
|
||||||
|
SLACK_TITLE: ${{ github.repository }}
|
||||||
|
MSG_MINIMAL: actions url,commit
|
||||||
|
SLACK_MESSAGE: |
|
||||||
|
${{ github.workflow }} for ${{ github.ref }} was a failure :rain_cloud:
|
||||||
|
|
||||||
|
Formatting: ${{ needs.format.result }}
|
||||||
|
Linter: ${{ needs.linter.result }}
|
||||||
|
Test: ${{ needs.test.result }}
|
||||||
|
Build: ${{ needs.build.result }}
|
||||||
Loading…
Reference in a new issue