Skip to content

Commit

Permalink
ci upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
idantavor committed Jul 16, 2024
1 parent 25f39f1 commit 6350659
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 76 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/build_test_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: "Pull Request Build & Test"

on:
pull_request:
types: [opened, synchronize, reopened]

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: Setup linter
uses: DeLaGuardo/setup-clj-kondo@master
with:
version: '2023.09.07'
- name: Lint
run: clj-kondo --lint src test --config '{:lint-as {clojure.test.check.properties/for-all clojure.core/let}}'

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

event_file:
needs: test
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v2
with:
name: Event File
path: ${{ github.event_path }}
101 changes: 101 additions & 0 deletions .github/workflows/ci_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
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 11
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 11

- 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: Setup linter
uses: DeLaGuardo/setup-clj-kondo@master
with:
version: '2023.09.07'
- name: Lint
run: clj-kondo --lint src test --config '{:lint-as {clojure.test.check.properties/for-all clojure.core/let}}'

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 11
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 11

- 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"
112 changes: 112 additions & 0 deletions .github/workflows/ci_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: "Push CI - master"

permissions:
contents: write

on:
push:
branches:
- 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 11
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 11

- 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: Setup linter
uses: DeLaGuardo/setup-clj-kondo@master
with:
version: '2023.09.07'
- name: Lint
run: clj-kondo --lint src test --config '{:lint-as {clojure.test.check.properties/for-all clojure.core/let}}'

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 11
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 11

- 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 release version
env:
RELEASE_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}$
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USER }}
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASS }}
run: |
git config --global user.name "github-actions-bot"
git config --global user.email "<>"
git config --global push.followTags true
lein pom
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:" $RELEASE_VERSION ", skipping deployment to Clojars..."
exit 0
fi
lein deploy
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
30 changes: 0 additions & 30 deletions .github/workflows/dev-build.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/main-build.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on: [workflow_call]

jobs:
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 11
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 11

- 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: Unit and Integration tests
run: lein eftest :all
Loading

0 comments on commit 6350659

Please sign in to comment.