Skip to content

Commit

Permalink
Feature/publish scylla and migration images (#4)
Browse files Browse the repository at this point in the history
* chore: workflows for release to ghcr

* chore: refactor npm build and rust build

* fix: revert version

* fix: update the file names

---------

Co-authored-by: Amninder Kaur <amninder.kaur@kindredgroup.com>
  • Loading branch information
akaur13 and Amninder Kaur authored Jan 8, 2024
1 parent 8dcfd80 commit d0098c3
Show file tree
Hide file tree
Showing 13 changed files with 2,202 additions and 993 deletions.
48 changes: 4 additions & 44 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,7 @@ name: build
on: push

jobs:
build:
runs-on: ubuntu-latest
environment: publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.75.0
with:
toolchain: stable
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
- name: Set up Database
run: docker-compose up -d

- name: Run Migrations
run: PATH=$PATH:$(pwd) bin/component-test-setup.sh

- name: cargo build
run: cargo build

- run: cargo test --examples
- run: cargo doc --no-deps

- run: bin/clippy-pedantic.sh

- run: cd scylla_pg_js && npm install

- name: component test
run: make withenv RECIPE=test.component

- name: component test lib
run: make withenv RECIPE=test.component.lib

- run: >
if [ $(bin/is-release.sh) = "1" ]; then
PATH=$PATH:$(pwd) bin/docker-push.sh
fi
rust_build:
uses: ./.github/workflows/rust_build.yml
npm_build:
uses: ./.github/workflows/npm_build.yml
37 changes: 37 additions & 0 deletions .github/workflows/ghcr_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: GHCR Publish

# when a new release is created or new tag is pushed to master
# tag should be in the format v1.0.0
# regex to check the tag format
on:
release:
types: [created]
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
uses: ./.github/workflows/rust_build.yml
publish:
runs-on: ubuntu-latest
needs: build
if: needs.build.result == 'success'
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: bin/ubuntu-setup.sh

- name: Build and publish scylla image with ver and latest tag
run: sh bin/ghcr-publish.sh scylla_pg_monitor

- name: Build and publish the pg-migration Docker image
run: sh bin/ghcr-publish.sh scylla_pg_migration


62 changes: 34 additions & 28 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
name: CI
on:
release:
types: [created]
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
DEBUG: napi:*
APP_NAME: scylla_pg_js
MACOSX_DEPLOYMENT_TARGET: '10.13'
'on':
push:


jobs:
npm_build:
uses: ./.github/workflows/npm_build.yml
build:
needs: npm_build
if: needs.npm_build.result == 'success'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -68,38 +78,35 @@ jobs:
run: ${{ matrix.settings.build }}
shell: bash

- name: setup docker container env for macos
run: brew install colima docker docker-compose
if: ${{ matrix.settings.host == 'macos-latest' }}
# - name: setup docker container env for macos
# run: brew install colima docker docker-compose
# if: ${{ matrix.settings.host == 'macos-latest' }}

- name: colima start for macos
run: colima start
if: ${{ matrix.settings.host == 'macos-latest' }}
# - name: colima start for macos
# run: colima start
# if: ${{ matrix.settings.host == 'macos-latest' }}

- name: Set up Database
run: docker-compose up -d
if: ${{ matrix.settings.host != 'windows-latest' }}
# - name: Set up Database
# run: docker-compose up -d
# if: ${{ matrix.settings.host != 'windows-latest' }}

- name: Sleep for 30s
uses: juliangruber/sleep-action@v2.0.0
with:
time: 30s
# - name: Sleep for 30s
# uses: juliangruber/sleep-action@v2.0.0
# with:
# time: 30s

- name: Run Migrations
run: PATH=$PATH:$(pwd) bin/component-test-setup.sh
if: ${{ matrix.settings.host != 'windows-latest' }}
# - name: Run Migrations
# run: PATH=$PATH:$(pwd) bin/component-test-setup.sh
# if: ${{ matrix.settings.host != 'windows-latest' }}

- name: component lib test
run: make withenv RECIPE=test.component.lib
if: ${{ matrix.settings.host != 'windows-latest' }}
# - name: component lib test
# run: make withenv RECIPE=test.component.lib
# if: ${{ matrix.settings.host != 'windows-latest' }}

- name: List packages
run: ls -R .
shell: bash

# - name: Test bindings
# run: cd scylla_pg_js && npm run test
# if: ${{ matrix.settings.target != 'aarch64-apple-darwin' }}

- name: Upload artifact
uses: actions/upload-artifact@v3
Expand All @@ -118,6 +125,7 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
needs:
- build
if: needs.build.result == 'success'
steps:
- uses: actions/checkout@v3
- name: Setup node
Expand All @@ -139,7 +147,5 @@ jobs:
- run: ls -R ./scylla_pg_js/artifacts

- name: Publish
run: >
if [ $(bin/is-release.sh) = "1" ]; then
PATH=$PATH:$(pwd) bin/npm-release.sh
fi
run: PATH=$PATH:$(pwd) bin/npm-release.sh # only run on release created or tag

26 changes: 26 additions & 0 deletions .github/workflows/npm_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# workflow_call to build the rust app
name: npm_build_and_test

on: workflow_call

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
- name: Set up Database
run: |
echo $(pwd)
ls -la
docker-compose up -d
- name: Run Migrations
run: PATH=$PATH:$(pwd) bin/component-test-setup.sh
- run: cd scylla_pg_js && npm install
- name: component test lib
run: make withenv RECIPE=test.component.lib
28 changes: 28 additions & 0 deletions .github/workflows/rust_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# workflow_call to build the rust app
name: rust_build_and_test

on: workflow_call

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.75.0
with:
toolchain: stable
- run: bin/ubuntu-setup.sh
- run: rustup component add rustfmt clippy
- name: cargo build
run: |
cargo clean
cargo build --release
- run: bin/pre-commit-checks.sh
- name: Set up Database
run: docker-compose up -d

- name: Run Migrations
run: PATH=$PATH:$(pwd) bin/component-test-setup.sh

- name: Component Tests
run: make withenv RECIPE=test.component
Loading

0 comments on commit d0098c3

Please sign in to comment.