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

Use scala.js for executable and docker image #531

Merged
merged 54 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
7a24c21
WIP
etspaceman Jul 7, 2023
5517f45
More WIP
etspaceman Jul 7, 2023
49dde84
More WIP
etspaceman Jul 7, 2023
4bcfa03
Remove
etspaceman Jul 7, 2023
e31d79c
Remove
etspaceman Jul 7, 2023
7964088
More WIP
etspaceman Jul 7, 2023
576d389
WIP
etspaceman Jul 8, 2023
fe2738e
More WIP
etspaceman Jul 8, 2023
df343d0
WIP
etspaceman Jul 8, 2023
55c55c1
We are compiling!
etspaceman Jul 10, 2023
afb0fa9
Merge remote-tracking branch 'origin/main' into sbt-typelevel
etspaceman Jul 10, 2023
f344f0b
more WIP
etspaceman Jul 10, 2023
4d67bc5
Merge remote-tracking branch 'origin/main' into scalajs
etspaceman Jul 10, 2023
db30007
WIP
etspaceman Jul 10, 2023
7d00eca
Things run now
etspaceman Jul 10, 2023
b1b020c
more WIP
etspaceman Jul 10, 2023
3ea769c
cleanup
etspaceman Jul 10, 2023
3ece1af
trying this but no luck
etspaceman Jul 10, 2023
5b3ae17
delete logs file
etspaceman Jul 10, 2023
cf892e9
snapshots
etspaceman Jul 11, 2023
53caf0d
fs2-io
etspaceman Jul 11, 2023
ff1be4c
fmt
etspaceman Jul 11, 2023
cba003f
add map file, enable source maps
etspaceman Jul 11, 2023
61573eb
don't rename file
etspaceman Jul 11, 2023
7c10964
fix jvmopts
etspaceman Jul 11, 2023
2c9b9ea
Update java version
etspaceman Jul 11, 2023
53625f4
More fixes for GHA
etspaceman Jul 11, 2023
22f1e99
More fixes
etspaceman Jul 11, 2023
b7c2149
fix
etspaceman Jul 11, 2023
9d40bf2
Only run integration tests on JS CI
etspaceman Jul 11, 2023
af36f5a
More fixes
etspaceman Jul 11, 2023
2fba860
Publish steps
etspaceman Jul 11, 2023
743464a
Fix linking steps, add compile step
etspaceman Jul 11, 2023
bd523ee
New FS2 snapshot, re-add logback to integration tests
etspaceman Jul 11, 2023
354911b
We are up and running!!
etspaceman Jul 11, 2023
ddf171e
efficiency
etspaceman Jul 11, 2023
21adb82
Doc Updates
etspaceman Jul 11, 2023
7f0e093
Make scalafix happy
etspaceman Jul 11, 2023
862818f
Increase timeout
etspaceman Jul 11, 2023
20e828c
Update docker push
etspaceman Jul 11, 2023
2aa012a
Support publishing to NPM
etspaceman Jul 12, 2023
5a1410c
enable binary
etspaceman Jul 12, 2023
43b46ae
Fix CI
etspaceman Jul 12, 2023
e659df9
FullOpt, retry unit tests
etspaceman Jul 12, 2023
4211211
Dont load source maps in docker image
etspaceman Jul 12, 2023
14f35da
Retry integration tests, add keywords
etspaceman Jul 12, 2023
2e375c8
Set scope
etspaceman Jul 12, 2023
105d674
properly scope package
etspaceman Jul 12, 2023
7e13630
fmt
etspaceman Jul 12, 2023
bc7bf65
fix CI
etspaceman Jul 12, 2023
4a7336e
Merge branch 'main' into scalajs
etspaceman Jul 19, 2023
b4f7bf9
Bump http4s
etspaceman Jul 21, 2023
9d5549a
Bump FS2
etspaceman Jul 31, 2023
ea52ea0
Update LibraryDependencies.scala
etspaceman Jul 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
318 changes: 318 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
# This file was automatically generated by sbt-github-actions using the
# githubWorkflowGenerate task. You should add and commit this file to
# your git repository. It goes without saying that you shouldn't edit
# this file by hand! Instead, if you wish to make changes, you should
# change your sbt build configuration to revise the workflow description
# to meet your needs, then regenerate this file.

name: Continuous Integration

on:
pull_request:
branches: ['**', '!update/**', '!pr/**']
push:
branches: ['**', '!update/**', '!pr/**']

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
name: Build and Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
scala: [2.13.11]
java: [temurin@17]
cbor_enabled: [true, false]
service_port: [4567, 4568]
project: [root-jvm-213, root-js-213]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download Java (temurin@17)
id: download-java-temurin-17
if: matrix.java == 'temurin@17'
uses: typelevel/download-java@v2
with:
distribution: temurin
java-version: 17

- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v3
with:
distribution: jdkfile
java-version: 17
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}

- name: Cache sbt
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Check that workflows are up to date
run: sbt githubWorkflowCheck

- name: Compile
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt 'project ${{ matrix.project }}' cpl

- name: Link JS
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest' && startsWith(matrix.project, 'root-js')
run: sbt 'project ${{ matrix.project }}' fastLinkJS

- name: Link Test JS
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest' && startsWith(matrix.project, 'root-js')
run: sbt 'project ${{ matrix.project }}' Test/fastLinkJS

- name: Unit Tests
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
uses: nick-fields/retry@v2
with:
timeout_minutes: 15
max_attempts: 3
command: sbt 'project ${{ matrix.project }}' unit-tests/test
retry_on: error

- name: Docker Compose Up
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest' && startsWith(matrix.project, 'root-js')
uses: nick-fields/retry@v2
with:
timeout_minutes: 15
retry_on: error
command: sbt 'project ${{ matrix.project }}' dockerComposeUp
on_retry_command: sbt 'project ${{ matrix.project }}' dockerComposeDown
max_attempts: 3

- name: Integration Tests
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest' && startsWith(matrix.project, 'root-js')
uses: nick-fields/retry@v2
with:
timeout_minutes: 15
max_attempts: 3
command: sbt 'project ${{ matrix.project }}' integration-tests/test
retry_on: error

- name: Print docker logs and container listing
if: ${{ failure() }}
run: sbt 'project ${{ matrix.project }}' dockerComposePs dockerComposeLogs

- name: Remove docker containers
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest' && startsWith(matrix.project, 'root-js')
run: sbt 'project ${{ matrix.project }}' dockerComposeDown

- name: Check scalafix lints
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt 'project ${{ matrix.project }}' fixCheck

publishDocker:
name: Publish Docker Image
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download Java (temurin@17)
id: download-java-temurin-17
if: matrix.java == 'temurin@17'
uses: typelevel/download-java@v2
with:
distribution: temurin
java-version: 17

- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v3
with:
distribution: jdkfile
java-version: 17
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}

- name: Cache sbt
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Compile
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' cpl

- name: Link JS
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' fullLinkJS

- name: Build Docker Image
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' kinesis-mockJS/buildDockerImage

- name: Login to registry
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin

- name: Push to registry
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: 'docker push ghcr.io/etspaceman/kinesis-mock:${{ github.event.release.tag_name }}'

publishJSAssets:
name: Publish JS Assets
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download Java (temurin@17)
id: download-java-temurin-17
if: matrix.java == 'temurin@17'
uses: typelevel/download-java@v2
with:
distribution: temurin
java-version: 17

- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v3
with:
distribution: jdkfile
java-version: 17
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}

- name: Cache sbt
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Compile
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' cpl

- name: Link JS
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' fullLinkJS

- name: Upload main.js
env:
GITHUB_TOKEN: '{{ secrets.GITHUB_TOKEN }}'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./docker/image/lib/main.js
asset_name: main.js
asset_content_type: text/javascript

- name: Upload main.js.map
env:
GITHUB_TOKEN: '{{ secrets.GITHUB_TOKEN }}'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./docker/image/lib/main.js.map
asset_name: main.js.map
asset_content_type: application/json

publishNPM:
name: Publish To NPM
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download Java (temurin@17)
id: download-java-temurin-17
if: matrix.java == 'temurin@17'
uses: typelevel/download-java@v2
with:
distribution: temurin
java-version: 17

- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v3
with:
distribution: jdkfile
java-version: 17
jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }}

- name: Cache sbt
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Compile
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' cpl

- name: Link JS
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' fullLinkJS

- name: Setup Node
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
env:
GITHUB_TOKEN: '{{ secrets.GITHUB_TOKEN }}'
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install artifacts to NPM
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' npmPackageInstall

- name: Publish artifacts to NPM
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: sbt '++ ${{ matrix.scala }}' npmPackageNpmrc npmPackagePublish
59 changes: 59 additions & 0 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This file was automatically generated by sbt-github-actions using the
# githubWorkflowGenerate task. You should add and commit this file to
# your git repository. It goes without saying that you shouldn't edit
# this file by hand! Instead, if you wish to make changes, you should
# change your sbt build configuration to revise the workflow description
# to meet your needs, then regenerate this file.

name: Clean

on: push

jobs:
delete-artifacts:
name: Delete Artifacts
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Delete artifacts
run: |
# Customize those three lines with your repository and credentials:
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
# A shortcut to call GitHub API.
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
# A temporary file which receives HTTP response headers.
TMPFILE=/tmp/tmp.$$
# An associative array, key: artifact name, value: number of artifacts of that name.
declare -A ARTCOUNT
# Process all artifacts on this repository, loop on returned "pages".
URL=$REPO/actions/artifacts
while [[ -n "$URL" ]]; do
# Get current page, get response headers in a temporary file.
JSON=$(ghapi --dump-header $TMPFILE "$URL")
# Get URL of next page. Will be empty if we are at the last page.
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
rm -f $TMPFILE
# Number of artifacts on this page:
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))
# Loop on all artifacts on this page.
for ((i=0; $i < $COUNT; i++)); do
# Get name of artifact and count instances of this name.
name=$(jq <<<$JSON -r ".artifacts[$i].name?")
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))
id=$(jq <<<$JSON -r ".artifacts[$i].id?")
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
ghapi -X DELETE $REPO/actions/artifacts/$id
done
done