Skip to content

Commit

Permalink
add branches ci step
Browse files Browse the repository at this point in the history
  • Loading branch information
idantavor committed Apr 28, 2024
1 parent df3f76f commit d9e9ae0
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 65 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/ci_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: "Push CI - branches"

on:
push:
branches-ignore:
- master

jobs:
build:
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Validate SNAPSHOT version
env:
SNAPSHOT_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}-SNAPSHOT$
if: github.ref != 'refs/heads/master'
run: |
lein pom
export VERSION=$(less pom.xml | grep "<version>" | head -1 | cut -d ">" -f2 | cut -d "<" -f1)
echo "Version is:" $VERSION
if [[ !("$VERSION" =~ $SNAPSHOT_REGEX) ]]
then
echo "Version isn't a SNAPSHOT version:" $VERSION
exit 0
fi
- name: Run linters
run: lein lint

test:
needs: build
uses: ./.github/workflows/test.yml

deploy:
needs: test
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Deploy SNAPSHOT version
env:
SNAPSHOT_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}-SNAPSHOT$
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }}
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }}
run: |
git config --global user.name "github-actions-bot"
git config --global user.email "<>"
lein pom
export SNAPSHOT_VERSION=$(less pom.xml | grep "<version>" | head -1 | cut -d ">" -f2 | cut -d "<" -f1)
echo "SNAPSHOT version is:" $SNAPSHOT_VERSION
if [[ !("$SNAPSHOT_VERSION" =~ $SNAPSHOT_REGEX) ]]
then
echo "Version isn't a SNAPSHOT version:" $SNAPSHOT_VERSION ", skipping deployment to Clojars..."
exit 0
fi
lein deploy
echo "SNAPSHOT version:" $SNAPSHOT_VERSION"; commit: "${{github.sha}}"; successfully deployed to Clojars"
111 changes: 46 additions & 65 deletions .github/workflows/ci_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,41 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v2

uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: zulu
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Validate SNAPSHOT version
env:
SNAPSHOT_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}-SNAPSHOT$
if: github.ref != 'refs/heads/master'
run: |
lein pom
export VERSION=$(less pom.xml | grep "<version>" | head -1 | cut -d ">" -f2 | cut -d "<" -f1)
echo "Version is:" $VERSION
if [[ !("$VERSION" =~ $SNAPSHOT_REGEX) ]]
then
echo "Version isn't a SNAPSHOT version:" $VERSION
exit 0
fi
- name: Setup linter
uses: DeLaGuardo/setup-clj-kondo@master
with:
Expand All @@ -37,65 +52,27 @@ jobs:

test:
needs: build
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK 8
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Generate proto files
run: lein protodeps generate

- name: Unit tests
env:
IP_STACK_ACCESS_KEY: ${{ secrets.IP_STACK_ACCESS_KEY }}
run: lein cloverage --html --lcov --junit

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1.19
#if: always()
if: false
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: "target/coverage/junit.xml"

- name: Coveralls
uses: coverallsapp/github-action@master
if: false
with:
path-to-lcov: "target/coverage/lcov.info"
github-token: ${{ secrets.GITHUB_TOKEN }}
uses: ./.github/workflows/test.yml

deploy:
needs: test
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v2

uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: zulu
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
Expand All @@ -113,15 +90,19 @@ jobs:
git config --global user.email "<>"
git config --global push.followTags true
lein pom
export VERSION=$(grep "<version>" pom.xml | head -1 | cut -d ">" -f2 | cut -d "<" -f1)
echo "version is:" $VERSION
if [[ !("$VERSION" =~ $RELEASE_REGEX) ]]
export ORIGINAL_VERSION=$(less pom.xml | grep "<version>" | head -1 | cut -d ">" -f2 | cut -d "<" -f1)
echo "Original version is:" $ORIGINAL_VERSION
lein change version leiningen.release/bump-version release
lein do vcs commit, install
lein pom
export RELEASE_VERSION=$(less pom.xml | grep "<version>" | head -1 | cut -d ">" -f2 | cut -d "<" -f1)
echo "Release version is:" $RELEASE_VERSION
if [[ !("$RELEASE_VERSION" =~ $RELEASE_REGEX) ]]
then
echo "Version isn't a release version:" $VERSION ", skipping deployment to Clojars..."
echo "Version isn't a release version:" $RELEASE_VERSION ", skipping deployment to Clojars..."
exit 0
fi
lein deploy
echo "Release version:" $VERSION"; commit: "${{github.sha}}"; successfully deployed to Clojars"
export TAG_NAME="v$VERSION"
git tag -a -m "Version $VERSION" $TAG_NAME
git push origin $TAG_NAME
echo "Release version:" $RELEASE_VERSION"; commit: "${{github.sha}}"; successfully deployed to Clojars"
git tag -a $RELEASE_VERSION -m "Release version $RELEASE_VERSION"
git push origin master
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on: [workflow_call]

jobs:
test:
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Generate proto files
run: lein protodeps generate

- name: Unit tests
env:
IP_STACK_ACCESS_KEY: ${{ secrets.IP_STACK_ACCESS_KEY }}
run: lein cloverage --html --lcov --junit

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1.19
#if: always()
if: false
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: "target/coverage/junit.xml"

- name: Coveralls
uses: coverallsapp/github-action@master
if: false
with:
path-to-lcov: "target/coverage/lcov.info"
github-token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit d9e9ae0

Please sign in to comment.