Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CAD-691] GitHub actions migration #368

Merged
merged 7 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 0 additions & 206 deletions .circleci/config.yml

This file was deleted.

9 changes: 9 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
run-name: Run Build

on:
push

jobs:
run_checks:
uses: ./.github/workflows/run_checks.yaml

35 changes: 35 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
run-name: Jackdaw build

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '*publish-snapshot*'

jobs:
run_checks:
uses: ./.github/workflows/run_checks.yaml
deploy:
needs: run_checks
runs-on: ubuntu-latest
container:
image: clojure:latest
environment: clojars_deploy
steps:
- name: checkout
uses: actions/checkout@v4
- name: deploy
env:
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }}
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
# https://github.com/actions/runner/issues/2033
git config --global --add safe.directory /__w/jackdaw/jackdaw
apt-get update
apt-get install -y gpg
echo $GPG_PRIVATE_KEY |base64 --decode |gpg --yes --batch --import
export LEIN_GPG=/__w/jackdaw/jackdaw/bin/gpg
export REAL_GPG=$(which gpg)
lein do jar, pom, deploy clojars

59 changes: 59 additions & 0 deletions .github/workflows/run_checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
run-name: Run checks

on:
workflow_call:

jobs:
RunChecks:
runs-on: ubuntu-latest
container:
image: clojure:latest
options: --user 1001 # don't run as root
services:
kafka:
image: confluentinc/cp-kafka:5.1.3
env:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_AUTO_CREATE_TOPICS_ENABLE: true
KAFKA_BROKER_ID: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
schema-registry:
image: confluentinc/cp-schema-registry:5.1.2
env:
SCHEMA_REGISTRY_HOST_NAME: schema-registry
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181'
kafka-rest:
image: confluentinc/cp-kafka-rest:6.1.1
env:
KAFKA_REST_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_REST_BOOTSTRAP_SERVERS: kafka:9092
KAFKA_REST_LISTENERS: http://0.0.0.0:8082
KAFKA_REST_SCHEMA_REGISTRY: http://schema-registry:8081
KAFKA_REST_HOST_NAME: kafka-rest
zookeeper:
image: confluentinc/cp-zookeeper:5.1.3
env:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
steps:
- name: checkout
uses: actions/checkout@v4
with:
# do not fetch tags if the trigger event is a tag push
fetch-tags: ${{ startsWith(github.ref, 'refs/tags') != true }}
fetch-depth: 100
- name: build
run: |
lein kaocha
env:
KAFKA_BOOTSTRAP_SERVERS: kafka
ZOOKEEPER_HOST: zoopkeeper
SCHEMA_REGISTRY_HOST: schema-registry
KAFKA_REST_PROXY_HOST: kafka-rest
- name: lint
run: lein clj-kondo --lint src test || true
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ See [an example using jackdaw](https://github.com/FundingCircle/topology-grapher

## Releasing

Anyone with the appropriate credentials can "cut a release" of jackdaw using the following steps.
Anyone with the appropriate credentials can "cut a release" of jackdaw
* Tags are protected, you will need to be a maintainer or admin to apply them
* Clojars deployment uses a protected env, once a tag is created, the CI job to deploy will need to be reviewed by the clojars env owner


Steps:
1. Review the diff of master vs the latest released tag (e.g. while preparing 0.7.0, I looked at https://github.com/FundingCircle/jackdaw/compare/0.6.9...master to see what was actually merged vs what was in the Changelog). Make a PR to put a date on the version being released and if necessary ensure completeness and consistency of the Changelog
2. Use the [Draft a new release](https://github.com/FundingCircle/jackdaw/releases/new) feature in github to prepare a release
3. In the "tag version" field, enter the proposed version
Expand All @@ -42,6 +46,10 @@ Anyone with the appropriate credentials can "cut a release" of jackdaw using the

Steps 2 to 6 is essentially `git tag $version -m "$title\n\n$description" && git push --tags`

#### Snapshot release

Snapshot releases can be created by pushing a tag with the format `publish-snapshot-semver`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean anyone can publish a snapshot release with any version they want?

Copy link
Collaborator Author

@jbropho jbropho Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Described slightly higher in the README, deploy env is protected, deploy step cannot run without approval from jackdaw or credit-applications team review.

In any case outside contributors don't have write access, PR's are opened via forks.


## License

Copyright © 2017 Funding Circle
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion .circleci/bin/gpg → bin/gpg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Invoked by `LEIN_GPG=$app/.circleci/bin/gpg lein deploy clojars`
# Invoked by `LEIN_GPG=$app/bin/gpg lein deploy clojars`

echo $GPG_PASSPHRASE \
| $REAL_GPG --pinentry-mode loopback --yes --batch --passphrase-fd=0 $@
7 changes: 5 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(defproject fundingcircle/jackdaw "_"
:description "A Clojure library for the Apache Kafka distributed streaming platform."

:license {:name "BSD 3-clause" :url "http://opensource.org/licenses/BSD-3-Clause"}

:scm {:name "git" :url "https://github.com/fundingcircle/jackdaw"}

:url "https://github.com/FundingCircle/jackdaw/"
Expand Down Expand Up @@ -33,12 +35,13 @@

:aliases {"kaocha" ["run" "-m" "kaocha.runner"]}
:aot [jackdaw.serdes.edn2 jackdaw.serdes.fressian jackdaw.serdes.fn-impl]
:plugins [[me.arrdem/lein-git-version "2.0.8"]]
:plugins [[me.arrdem/lein-git-version "2.0.8"]
[com.github.clj-kondo/lein-clj-kondo "0.2.5"]]

:git-version
{:status-to-version
(fn [{:keys [tag branch ahead? dirty?] :as git}]
(if (and tag (not ahead?) (not dirty?))
(if (and tag (not ahead?) (not dirty?) (= "master" branch))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be handled with trigger filters in the workflow def?

Copy link
Collaborator Author

@jbropho jbropho Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to make more explicit that all non-master builds are marked snapshot; it should be handled already by the current setup, happy to remove it if it adds confusion.

tag
(let [[_ prefix patch] (re-find #"(\d+\.\d+)\.(\d+)" tag)
patch (Long/parseLong patch)
Expand Down
5 changes: 3 additions & 2 deletions test/jackdaw/client/partitioning_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
(:require
[clojure.test :refer [deftest is testing]]
[jackdaw.client :as client]
[jackdaw.client.partitioning :as part]))
[jackdaw.client.partitioning :as part]
[jackdaw.utils :as utils]))

(set! *warn-on-reflection* false)

Expand All @@ -22,7 +23,7 @@


(deftest test->ProducerRecord
(with-open [p (client/producer {"bootstrap.servers" "localhost:9092"
(with-open [p (client/producer {"bootstrap.servers" (str (utils/bootstrap-servers) ":9092")
"key.serializer" "org.apache.kafka.common.serialization.StringSerializer"
"value.serializer" "org.apache.kafka.common.serialization.StringSerializer"})]
(testing "absent key-fn"
Expand Down
Loading