Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdbd committed Oct 9, 2024
1 parent 318ebda commit d478d72
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 53 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ jobs:

- name: 📦 Create archives for all assets to be included in the GitHub release
run: |
zip "${{ env.BINARY_NAME }}-${{ env.VERSION }}-ubuntu-latest-amd64.zip" linux-amd64-binary
zip "${{ env.BINARY_NAME }}-${{ env.VERSION }}-macos-latest-aarch64.zip" macos-aarch64-binary
mv linux-amd64-binary fosdem-dl && zip "${{ env.BINARY_NAME }}-${{ env.VERSION }}-linux-amd64.zip" fosdem-dl && rm fosdem-dl
mv macos-aarch64-binary fosdem-dl && zip "${{ env.BINARY_NAME }}-${{ env.VERSION }}-macos-aarch64.zip" fosdem-dl && rm fosdem-dl
# Troubleshooting: do we have every assets we want to include in the GitHub release?
- run: ls -la
Expand All @@ -340,18 +340,15 @@ jobs:
uses: softprops/action-gh-release@v2
id: github_release
with:
body: |
📦 **${{ env.UBERJAR_NAME }}** version `${{ env.VERSION }}`.
You will also need to download a [release of pod-jackdbd-jsoup](https://github.com/jackdbd/pod-jackdbd-jsoup/releases) and extact the pod to `resources/pod/pod-jackdbd-jsoup`.
body_path: ${{ github.workspace }}/docs/release-body.md
# draft: true
fail_on_unmatched_files: true
# TODO: add all binaries compiled with GraalVM native-image
files: |
${{ env.UBERJAR_NAME }}-${{ env.VERSION }}.jar
${{ env.UBERJAR_NAME }}-${{ env.VERSION }}-standalone.jar
${{ env.BINARY_NAME }}-${{ env.VERSION }}-macos-latest-aarch64.zip
${{ env.BINARY_NAME }}-${{ env.VERSION }}-ubuntu-latest-amd64.zip
${{ env.BINARY_NAME }}-${{ env.VERSION }}-linux-amd64.zip
${{ env.BINARY_NAME }}-${{ env.VERSION }}-macos-aarch64.zip
# body is prepended to these automatically generated release notes.
# See here for how to configure these release notes:
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes
Expand Down
34 changes: 6 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,7 @@ Download all talks from a [FOSDEM](https://fosdem.org/) conference track in a sp

## Installation

>[!IMPORTANT]
> At the moment this project is only available on [GitHub Releases](https://github.com/jackdbd/fosdem-dl/releases) as [Babashka uberjar](https://book.babashka.org/#_uberjar).
To use the CLI you will need to have:

1. [Babashka](https://babashka.org/) installed on your machine.
1. A [pod-jackdbd-jsoup](https://github.com/jackdbd/pod-jackdbd-jsoup) binary for your combination of OS/architecture.
1. Execution permissions on the pod binary (e.g. `chmod +x pod-jackdbd-jsoup`).
1. A file structure like the one below.

```sh
.
├── fosdem-dl-0.1.0-RC.1.jar
└── resources
└── pod
└── pod-jackdbd-jsoup
```

If all these requirements are met, you can use the CLI with:

```sh
bb fosdem-dl-0.1.0-RC.1.jar
```

>[!NOTE]
> I'm trying to understand how to bundle a Babashka pod in a binary compiled with GraalVM native-image.
This project is available on [GitHub Releases](https://github.com/jackdbd/fosdem-dl/releases) as an uberjar and a [Babashka uberjar](https://book.babashka.org/#_uberjar).

## Usage

Expand Down Expand Up @@ -80,7 +55,7 @@ Examples:
fosdem-dl tracks -y 2020
```
>[!TIP]
> [!TIP]
> You can invoke the help of each command with `-h`, `--help`, `:h`, or `:help`.
### Examples
Expand Down Expand Up @@ -113,12 +88,15 @@ This project uses a [`bb.edn`](./bb.edn) file to define a few [Babashka tasks](h

A specific version of `pod-jackdbd-jsoup` might not be *registered* on the [Babashka pod registry](https://github.com/babashka/pod-registry), but you can always download that pod from [GitHub Releases](https://github.com/jackdbd/pod-jackdbd-jsoup/releases).

Make sure to set the environment variable `POD_JACKDBD_JSOUP_VERSION` to the desired version, then run this script.
Make sure to set the environment variable `POD_JACKDBD_JSOUP_VERSION` to the desired version, then run this script (you will need to have the [GitHub CLI](https://cli.github.com/) installed).

```sh
./download_pod_jackdbd_jsoup.sh
```

> [!NOTE]
> `pod-jackdbd-jsoup` is available both as a binary and as an uberjar. This script will download both.

### Namespace dependency graph

![Dependency graph of the namespaces, generated with clj-hiera](./resources/img/namespaces.png)
Expand Down
3 changes: 2 additions & 1 deletion bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
:min-bb-version "1.3.189"
:paths ["bb" "src" "resources"]
:pods {com.github.jackdbd/jsoup {:version "0.4.0"}
;; com.github.jackdbd/pod-jackdbd-jsoup {:path "./resources/pod/pod-jackdbd-jsoup"}
;; for a local pod:
;; com.github.jackdbd/jsoup {:path "/home/jack/.babashka/pods/pod-jackdbd-jsoup"}
}

:tasks
Expand Down
6 changes: 6 additions & 0 deletions bb/demo_jsoup.bb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
(maybe-video-url {:html html})
(attachment-urls {:html html})

(pods/unload-pod "pod.jackdbd.jsoup")

(def pod-spec (pods/load-pod 'com.github.jackdbd/jsoup "0.4.0"))
(require '[pod.jackdbd.jsoup :as jsoup])
(pods/unload-pod pod-spec)

;; Load the pod by evaluating one of the following two lines
(def pod-spec (pods/load-pod ["java" "-jar" uber-file]))
(def pod-spec (pods/load-pod exe-file))
Expand Down
4 changes: 2 additions & 2 deletions dev/user.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
[babashka.http-client :as http]
[clojure.java.io :as io]
[fosdem-dl.download :refer [download-all!]]
[fosdem-dl.pods :refer [pod-specs]]
[fosdem-dl.scraping :refer [attachment-urls
conference-track-urls
jsoup-node-element->href
jsoup-pod
maybe-video-url]]
[fosdem-dl.talks-cli :refer [talks-cli]]
[fosdem-dl.tracks-cli :refer [tracks-cli]]
Expand All @@ -26,7 +26,7 @@
(maybe-video-url {:html html})
(attachment-urls {:html html})

(pods/unload-pod @jsoup-pod))
(pods/unload-pod (:jsoup @pod-specs))

(require '[babashka.pods :as pods])
(def pod-spec (pods/load-pod 'com.github.jackdbd/jsoup "0.4.0"))
Expand Down
2 changes: 2 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
packages = with pkgs; [
babashka # Clojure interpreter for scripting
dive # tool for exploring layers in a container image
gh # GitHub CLI
git

# musl is required by GraalVM native-image when compiling a statically
Expand Down Expand Up @@ -68,6 +69,7 @@
bb --version
dive --version
dot --version
gh --version
git --version
java --version
native-image --version
Expand Down
26 changes: 26 additions & 0 deletions docs/release-body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
fosdem-dl is available as uberjar or Babashka uberjar.

## Uberjar

To run the uberjar you will need to have a JRE installed on your machine.

```sh
java -jar fosdem-dl-0.1.0-RC.1-standalone.jar
```

## Babashka uberjar

To run the [Babashka uberjar](https://book.babashka.org/#_uberjar) you will need to have [Babashka](https://babashka.org/) installed on your machine.

```sh
bb fosdem-dl-0.1.0-RC.1.jar
```

## Container image [TODO]

The CLI can be built as a container image (see `bb.edn`). I just need to push the container image on [Container registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry).

## Binary [TODO]

> [!WARNING]
> GraalVM native-image can produce binaries for this CLI, but they immediately crash at runtime. I'm investigating the issue.
13 changes: 7 additions & 6 deletions download_pod_jackdbd_jsoup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ POD_NAME=pod-jackdbd-jsoup
POD_VERSION=$POD_JACKDBD_JSOUP_VERSION
ARCH=amd64
OS=ubuntu-latest

echo "Download assets published on GitHub release"
BABASHKA_PODS_DIR_DEFAULT=$HOME/.babashka/pods
BABASHKA_PODS_DIR=${BABASHKA_PODS_DIR:-$BABASHKA_PODS_DIR_DEFAULT}
UBERJAR="$POD_ID-$POD_VERSION-standalone.jar"
ZIP_BINARY="$POD_NAME-$POD_VERSION-$OS-$ARCH.zip"

echo "Download assets published on GitHub release to $BABASHKA_PODS_DIR"
gh release download "v$POD_VERSION" \
--clobber \
--dir resources/pod \
--dir $BABASHKA_PODS_DIR \
--repo jackdbd/pod-jackdbd-jsoup \
--pattern "$UBERJAR" \
--pattern "$ZIP_BINARY"

pushd . && cd resources/pod && unzip -o "$ZIP_BINARY" && popd
pushd . && cd $BABASHKA_PODS_DIR && unzip -o "$ZIP_BINARY" && popd

chmod +x "resources/pod/$POD_NAME"
chmod +x "$BABASHKA_PODS_DIR/$POD_NAME"

rm "resources/pod/$ZIP_BINARY"
rm "$BABASHKA_PODS_DIR/$ZIP_BINARY"
Binary file modified resources/img/namespaces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/fosdem_dl/cli.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"CLI to download the talks given at FOSDEM over the years."
(:gen-class)
(:require
[babashka.pods :as pods]
[clojure.string :as str]
[fosdem-dl.scraping :refer [jsoup-pod]]
[fosdem-dl.talks-cli :refer [talks-cli]]
[fosdem-dl.tracks-cli :refer [tracks-cli]]))

Expand Down Expand Up @@ -47,7 +45,6 @@ Available commands: %s" (str/join ", " available-commands)))]
(when-let [stderr (:sterr result)]
(println "ERRORS")
(println stderr))
(pods/unload-pod @jsoup-pod)
(System/exit (:exit-code result))))

;; TODO: do I need to call pods/unload when exiting? Otherwise it seems the CLI
Expand Down
3 changes: 3 additions & 0 deletions src/fosdem_dl/pods.cljc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(ns fosdem-dl.pods)

(def pod-specs (atom {}))
11 changes: 6 additions & 5 deletions src/fosdem_dl/scraping.cljc
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
(ns fosdem-dl.scraping
(:require
#?(:bb [pod.jackdbd.jsoup :as jsoup]
:clj [babashka.pods :as pods])
:clj [babashka.pods :as pods])
[clojure.core :refer [format]]
[clojure.string :as str]
[fosdem-dl.defaults :as default]
[taoensso.timbre :refer [debug warn]]))

(def jsoup-pod (atom nil))

;; When running on Babashka we have already imported the pod, so we have nothing
;; to require/load here. We still need to define a match for the reader
;; conditional though, because otherwise Babashka will match the :clj branch.
;; Also, make sure the version of the pod is the same as the one in the bb.edn.
#?(:bb nil
:clj (do (reset! jsoup-pod (pods/load-pod 'com.github.jackdbd/jsoup "0.4.0"))
(require '[pod.jackdbd.jsoup :as jsoup])))
:clj (do (require '[fosdem-dl.pods :refer [pod-specs]])
;; for a local pod: (pods/load-pod "/home/jack/.babashka/pods/pod-jackdbd-jsoup")
(let [pod-spec (pods/load-pod 'com.github.jackdbd/jsoup "0.4.0")]
(swap! pod-specs assoc :jsoup pod-spec)
(require '[pod.jackdbd.jsoup :as jsoup]))))

(defn maybe-video-url
"Extracts the <video> `src` attribute from an HTML string."
Expand Down

0 comments on commit d478d72

Please sign in to comment.