From 463037c3acd7aa07b33e06c21e186e8179663bb3 Mon Sep 17 00:00:00 2001 From: Kimo Knowles Date: Tue, 23 Apr 2024 21:55:54 +0200 Subject: [PATCH] [wip] rewrite CI --- .../continuous-deployment-workflow.yml | 130 ------------------ .../continuous-integration-workflow.yml | 93 ++++++------- .github/workflows/docs-workflow.yml | 78 ----------- .gitignore | 1 + bb.edn | 25 ++++ shadow-cljs.edn | 5 +- 6 files changed, 75 insertions(+), 257 deletions(-) delete mode 100644 .github/workflows/continuous-deployment-workflow.yml delete mode 100644 .github/workflows/docs-workflow.yml create mode 100644 bb.edn diff --git a/.github/workflows/continuous-deployment-workflow.yml b/.github/workflows/continuous-deployment-workflow.yml deleted file mode 100644 index 5227f145..00000000 --- a/.github/workflows/continuous-deployment-workflow.yml +++ /dev/null @@ -1,130 +0,0 @@ -name: cd -on: - push: - tags: - - "v[0-9]+.[0-9]+.[0-9]+*" - -jobs: - test: - name: Test - runs-on: ubuntu-20.04 - container: - # Source: https://github.com/day8/dockerfiles-for-dev-ci-images - image: ghcr.io/day8/chrome-56:2 - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v1 - - name: Maven cache - id: maven-cache - uses: actions/cache@v1 - with: - path: /root/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/project.clj', '.github/workflows/**') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: npm cache - uses: actions/cache@v1 - with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('project.clj') }}-${{ hashFiles('**/deps.cljs') }} - restore-keys: | - ${{ runner.os }}-npm- - - name: shadow-cljs compiler cache - uses: actions/cache@v1 - with: - path: .shadow-cljs - key: ${{ runner.os }}-shadow-cljs-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-shadow-cljs- - - if: steps.maven-cache.outputs.cache-hit != 'true' - run: | - lein ci - lein prod-once - - if: steps.maven-cache.outputs.cache-hit == 'true' - run: | - lein -o ci - lein -o prod-once - - name: Slack notification - uses: homoluctus/slatify@v2.0.1 - if: failure() || cancelled() - with: - type: ${{ job.status }} - job_name: re-com Tests - channel: '#oss-robots' - url: ${{ secrets.SLACK_WEBHOOK }} - commit: true - token: ${{ secrets.GITHUB_TOKEN }} - release: - name: Release - needs: test - runs-on: ubuntu-20.04 - container: - # Source: https://github.com/day8/dockerfiles-for-dev-ci-images - image: ghcr.io/day8/chrome-56:2 - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} - CLOJARS_TOKEN: ${{ secrets.CLOJARS_TOKEN }} - steps: - - uses: actions/checkout@v1 - - name: Maven cache - id: maven-cache - uses: actions/cache@v1 - with: - path: /root/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/project.clj', '.github/workflows/**') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Run lein release - if: steps.maven-cache.outputs.cache-hit != 'true' - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} - CLOJARS_TOKEN: ${{ secrets.CLOJARS_TOKEN }} - GITHUB_USERNAME: ${{ github.actor }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - lein release - - name: Run lein -o release - if: steps.maven-cache.outputs.cache-hit == 'true' - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} - CLOJARS_TOKEN: ${{ secrets.CLOJARS_TOKEN }} - GITHUB_USERNAME: ${{ github.actor }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - lein -o release - # This creates a 'GitHub Release' from the tag and includes link to CHANGELOG.md at the current - # git ref. We do not use draft or prerelease features as we always want - # the latest release to show in the right hand column of the project page regardless - # of if it is a stable release. - - name: Create GitHub Release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - body: | - [Changelog](https://github.com/day8/re-com/blob/master/CHANGELOG.md) - draft: false - prerelease: false - - name: Slack notification - uses: homoluctus/slatify@v2.0.1 - if: always() - with: - type: ${{ job.status }} - job_name: re-com Deployment - channel: '#oss-robots' - url: ${{ secrets.SLACK_WEBHOOK }} - commit: true - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index ef6e6fce..fc6184c2 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -2,58 +2,59 @@ name: ci on: [push] jobs: + test: + name: Test - runs-on: ubuntu-20.04 - container: - # Source: https://github.com/day8/dockerfiles-for-dev-ci-images - image: ghcr.io/day8/chrome-56:2 - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + + runs-on: ubuntu-22.04 + steps: - - uses: actions/checkout@v1 - - name: Maven cache - uses: actions/cache@v1 - id: maven-cache + - uses: actions/checkout@v4 + + - name: Setup java + uses: actions/setup-java@v3 with: - path: /root/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('project.clj', 'deps.edn', '.github/workflows/**') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: npm cache - uses: actions/cache@v1 + distribution: 'temurin' + java-version: '21' + + - name: Install clojure tools + uses: DeLaGuardo/setup-clojure@12.5 with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('package.json', 'package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- - - name: shadow-cljs compiler cache - uses: actions/cache@v1 + cli: 'latest' + bb: 'latest' + + - name: Cache clojure dependencies + uses: actions/cache@v3 with: - path: .shadow-cljs - key: ${{ runner.os }}-shadow-cljs-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-shadow-cljs- - - if: steps.maven-cache.outputs.cache-hit != 'true' - run: | - lein ci - lein build-report-ci - - if: steps.maven-cache.outputs.cache-hit == 'true' - run: | - lein -o ci - lein -o build-report-ci - - uses: actions/upload-artifact@v2 + path: | + ~/.m2/repository + ~/.gitlibs + ~/.deps.clj + ~/.npm + .shadow-cljs + key: cljdeps-${{ hashFiles('deps.edn') }} + restore-keys: cljdeps- + + - name: Fix git dubious directory ownership error + run: git config --global --add safe.directory /__w/re-com/re-com + + - run: bb ci + + - run: bb build-report-ci + + - uses: actions/upload-artifact@v4 with: name: build-report path: target/build-report.html - - name: Slack notification - uses: homoluctus/slatify@v2.0.1 - if: failure() || cancelled() - with: - type: ${{ job.status }} - job_name: re-com Tests - channel: '#oss-robots' - url: ${{ secrets.SLACK_WEBHOOK }} - commit: true - token: ${{ secrets.GITHUB_TOKEN }} + + # - name: Slack notification + # uses: homoluctus/slatify@v2.0.1 + # if: failure() || cancelled() + # with: + # type: ${{ job.status }} + # job_name: re-com Tests + # channel: '#oss-robots' + # url: ${{ secrets.SLACK_WEBHOOK }} + # commit: true + # token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/docs-workflow.yml b/.github/workflows/docs-workflow.yml deleted file mode 100644 index a96f766e..00000000 --- a/.github/workflows/docs-workflow.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: re-com.day8.com.au -on: - push: - branches: - - master - -jobs: - deploy: - name: Deploy - runs-on: ubuntu-20.04 - container: - # Source: https://github.com/day8/dockerfiles-for-dev-ci-images - image: ghcr.io/day8/chrome-56:2 - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} - CLOJARS_TOKEN: ${{ secrets.CLOJARS_TOKEN }} - steps: - - uses: actions/checkout@v1 - - name: Maven cache - id: maven-cache - uses: actions/cache@v1 - with: - path: /root/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/project.clj') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: npm cache - uses: actions/cache@v1 - with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('project.clj') }}-${{ hashFiles('**/deps.cljs') }} - restore-keys: | - ${{ runner.os }}-npm- - - name: Run lein deploy-aws - if: steps.maven-cache.outputs.cache-hit != 'true' - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} - CLOJARS_TOKEN: ${{ secrets.CLOJARS_TOKEN }} - GITHUB_USERNAME: ${{ github.actor }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - AWS_EC2_METADATA_DISABLED: true - run: | - lein deploy-aws - - name: Run lein -o deploy-aws - if: steps.maven-cache.outputs.cache-hit == 'true' - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} - CLOJARS_TOKEN: ${{ secrets.CLOJARS_TOKEN }} - GITHUB_USERNAME: ${{ github.actor }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - AWS_EC2_METADATA_DISABLED: true - run: | - lein -o deploy-aws - - name: Invalidate CloudFront Distribution - uses: chetan/invalidate-cloudfront-action@master - env: - DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} - PATHS: '/*' - AWS_REGION: 'us-east-1' - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - - name: Slack notification - uses: homoluctus/slatify@v2.0.1 - if: always() - with: - type: ${{ job.status }} - job_name: re-com.day8.com.au Deployment - username: "Github Actions" - channel: '#oss-robots' - url: ${{ secrets.SLACK_WEBHOOK }} - commit: true - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 9dde18b6..e0aebf4b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.log .nrepl-* .lein-* +public pom.xml pom.xml.asc core/ diff --git a/bb.edn b/bb.edn new file mode 100644 index 00000000..5edd5670 --- /dev/null +++ b/bb.edn @@ -0,0 +1,25 @@ +{:min-bb-version "0.4.0" + :tasks + {:requires ([babashka.fs :as fs]) + clean (let [clean-targets ["node_modules" + "run/resources/public/compiled_dev " + "run/resources/public/compiled_prod" + "run/resources/public/compiled_test"]] + (doseq [target clean-targets] + (println "bb clean: deleting" target) + (fs/delete-tree target))) + install (shell "npm install") + test {:depends [clean install] + :task (do (shell "npx shadow-cljs compile karma-test") + (shell "npx karma start --single-run --reporters junit,dots"))} + release-demo {:depends [clean install] + :task (shell "npx shadow-cljs release demo")} + prod-once {:depends [release-demo]} + ci {:depends [clean install release-demo]} + build-report-ci {:depends [clean install] + :task (shell + "npx shadow-cljs clj-run shadow.cljs.build-report demo target/build-report.html")} + watch {:depends [clean install] + :task (shell "npx shadow-cljs watch demo browser-test karma-test")} + deploy-aws {:depends [ci] + :task (shell "aws s3 sync run/resources/public s3://re-demo/ --acl public-read --cache-control max-age=2592000,public")}}} diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 8b07cf6d..6d489cf9 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -1,4 +1,4 @@ -{:lein {:profile "+demo"} +{:deps true :nrepl {:port 7777} :builds {:demo @@ -23,8 +23,7 @@ re-com.config/root-url-for-compiler-output "http://localhost:3449/compiled_dev/demo/cljs-runtime/"} :external-config {:devtools/config {:features-to-install [:formatters :hints]}}}} - :release {:output-dir "run/resources/public/compiled_prod/demo" - :compiler-options {:closure-defines {;; For production builds, such as the demo website, there is no source + :release {:compiler-options {:closure-defines {;; For production builds, such as the demo website, there is no source ;; code to link to in validation errors or component stacks, so we set ;; it to an empty string to cause links to not be displayed at all. re-com.config/root-url-for-compiler-output ""}}}