Publish #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
workflow_dispatch: | |
jobs: | |
test_core: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./core | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run tests | |
run: | | |
cargo test -- --skip smoke_memory | |
test_service: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./service | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run tests | |
run: | | |
export MERITRANK_NUM_WALK=50 | |
cargo test | |
test_psql_connector: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./psql-connector | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PostgreSQL 16 | |
run: | | |
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get install -y postgresql-16 postgresql-server-dev-16 | |
- name: Prepare env | |
run: | | |
sudo su - root -c "echo \"export MERITRANK_SERVICE_URL=tcp://127.0.0.1:10444\" >> /etc/environment" | |
- name: Build the connector | |
run: | | |
cargo install --locked cargo-pgrx --version 0.11.4 | |
cargo pgrx init --pg16 pg_config | |
cargo build | |
- name: Build and run the service | |
working-directory: ./service | |
run: | | |
cargo build --release | |
export MERITRANK_SERVICE_URL=tcp://127.0.0.1:10444 | |
export MERITRANK_NUM_WALK=500 | |
cargo run --release >/dev/null 2>&1 & | |
- name: Do the tests | |
run: | | |
export RUST_TEST_THREADS=1 | |
cargo pgrx test --runas postgres --pgdata /var/lib/postgresql/pgrx | |
publish_service: | |
needs: [ test_core, test_service, test_psql_connector ] | |
if: success() | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./service | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check version | |
id: check_version | |
shell: bash | |
run: | | |
export VER=$(cargo metadata --format-version=1 | jq -r '.packages[] | select(.name=="meritrank_service") | .version') | |
echo "VER=$VER" | |
if ! [[ "$VER" =~ ^[0-9\.]+$ ]]; then | |
echo "IGNORE DEV VERSION" | |
echo "SKIP=1" >> "$GITHUB_OUTPUT" | |
exit 0 | |
fi | |
if [ $(docker manifest inspect vbulavintsev/meritrank-service:v$VER >/dev/null 2>&1; echo $?) -eq 0 ]; then | |
echo "ALREADY PUBLISHED" | |
echo "SKIP=1" >> "$GITHUB_OUTPUT" | |
exit 0 | |
fi | |
echo "SKIP=0" >> "$GITHUB_OUTPUT" | |
echo "TAG=v$VER" >> "$GITHUB_ENV" | |
- name: Build docker image | |
if: ${{ steps.check_version.outputs.SKIP == 0 }} | |
run: | | |
docker build -t vbulavintsev/meritrank-service:$TAG -f ./Dockerfile .. | |
- name: Push docker image to Dockerhub | |
if: ${{ steps.check_version.outputs.SKIP == 0 }} | |
shell: bash | |
run: | | |
docker login -u vbulavintsev -p ${{ secrets.DOCKERHUB_TOKEN }} | |
docker image push vbulavintsev/meritrank-service:$TAG | |
publish_connector: | |
needs: [ test_core, test_service, test_psql_connector ] | |
if: success() | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./psql-connector | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check version | |
id: check_version | |
shell: bash | |
run: | | |
export VER=$(cargo metadata --format-version=1 | jq -r '.packages[] | select(.name=="pgmer2") | .version') | |
echo "VER=$VER" | |
if ! [[ "$VER" =~ ^[0-9\.]+$ ]]; then | |
echo "IGNORE DEV VERSION" | |
echo "SKIP=1" >> "$GITHUB_OUTPUT" | |
exit 0 | |
fi | |
if [ $(docker manifest inspect vbulavintsev/postgres-tentura:v$VER >/dev/null 2>&1; echo $?) -eq 0 ]; then | |
echo "ALREADY PUBLISHED" | |
echo "SKIP=1" >> "$GITHUB_OUTPUT" | |
exit 0 | |
fi | |
echo "SKIP=0" >> "$GITHUB_OUTPUT" | |
echo "TAG=v$VER" >> "$GITHUB_ENV" | |
- name: Build docker image | |
if: ${{ steps.check_version.outputs.SKIP == 0 }} | |
run: | | |
docker build -t vbulavintsev/postgres-tentura:$TAG -f ./Dockerfile .. | |
- name: Push docker image to Dockerhub | |
if: ${{ steps.check_version.outputs.SKIP == 0 }} | |
shell: bash | |
run: | | |
docker login -u vbulavintsev -p ${{ secrets.DOCKERHUB_TOKEN }} | |
docker image push vbulavintsev/postgres-tentura:$TAG |