Skip to content

Implement redis cache #328

Implement redis cache

Implement redis cache #328

Workflow file for this run

name: Test & Release
on:
push:
branches:
- master
- dev
pull_request:
branches:
- master
- dev
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: FedericoCarboni/setup-ffmpeg@v2
- uses: actions/setup-go@v5
with:
go-version: '1.23'
id: go
- name: Retrieve release details
id: release_details
run: |
echo "APP_NAME=$(git describe --tags|sed -e 's/\-v.*//')" >> $GITHUB_ENV
echo "APP_VERSION=$(git describe --tags --match 'api-v*'|sed 's/api-v\([0-9.]*\)/\1/')" >> $GITHUB_ENV
- name: Release details
run: |
echo "::group::app ${{ env.APP_NAME }}"
echo "version ${{ env.APP_VERSION }}"
echo "env ${{ github.ref }}"
echo "::endgroup::"
- name: Set up containers
run: docker compose up -d
- name: Set up containers
run: docker compose -f apps/watchman/docker-compose.yml up -d clickhouse geoipupdate
- name: Check running containers
run: docker ps -a
- name: Prepare for tests
run: make prepare_test
- name: Wait for wallet init
run: scripts/wait_for_wallet.sh
- name: Test
env:
OAUTH_TEST_CLIENT_SECRET: ${{ secrets.OAUTH_TEST_CLIENT_SECRET }}
OAUTH_TEST_USERNAME: ${{ secrets.OAUTH_TEST_USERNAME }}
OAUTH_TEST_PASSWORD: ${{ secrets.OAUTH_TEST_PASSWORD }}
REAL_WALLET_PRIVATE_KEY: ${{ secrets.REAL_WALLET_PRIVATE_KEY }}
REAL_WALLET_PUBLIC_KEY: ${{ secrets.REAL_WALLET_PUBLIC_KEY }}
BUYER_WALLET_PRIVATE_KEY: ${{ secrets.BUYER_WALLET_PRIVATE_KEY }}
BUYER_WALLET_PUBLIC_KEY: ${{ secrets.BUYER_WALLET_PUBLIC_KEY }}
REFLECTOR_UPLINK: ${{ secrets.REFLECTOR_UPLINK }}
run: |
go install github.com/jandelgado/gcov2lcov@latest
go test -short -covermode=count -coverprofile=coverage.out ./... && gcov2lcov -infile=coverage.out -outfile=coverage.lcov
- uses: coverallsapp/github-action@v2
with:
file: coverage.lcov
github-token: ${{ secrets.GITHUB_TOKEN }}
release:
name: release
needs: test
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.23'
id: go
- run: git branch
- name: Retrieve release details
id: release
run: |
echo "APP_NAME=$(git describe --tags|sed -e 's/\-v.*//')" >> $GITHUB_ENV
echo "APP_VERSION=$(git describe --tags --match 'api-v*'|sed 's/api-v\([0-9.]*\)/\1/')" >> $GITHUB_ENV
- name: Release details
run: |
echo "::group::${{ env.APP_NAME }}"
echo "version ${{ env.APP_VERSION }}"
echo "env ${{ github.ref }}"
echo "::endgroup::"
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# odysee-api deployment
- name: Build odysee-api
if: env.APP_NAME == 'api'
run: make oapi
- name: Build and push odysee-api docker image
if: env.APP_NAME == 'api'
uses: docker/build-push-action@v2
with:
push: true
context: .
tags: |
odyseeteam/odysee-${{ env.APP_NAME }}:latest
odyseeteam/odysee-${{ env.APP_NAME }}:${{ env.APP_VERSION }}
- name: Deploy odysee-api
if: env.APP_NAME == 'api'
uses: octokit/[email protected]
id: deploy-odysee-api
env:
GITHUB_TOKEN: ${{ secrets.DEPLOYMENT_REPO_TOKEN }}
with:
route: POST /repos/:repository/dispatches
repository: odyseeteam/misc-deployment
event_type: deploy-odysee
client_payload: |
tag: ${{ env.APP_VERSION }}
ref: ${{ github.ref }}
service: odysee-api
# Watchman deployment
- name: Build watchman
if: env.APP_NAME == 'watchman'
run: make watchman
- name: Build watchman docker image
if: env.APP_NAME == 'watchman'
uses: docker/build-push-action@v2
with:
push: true
context: apps/${{ env.APP_NAME }}/
tags: |
odyseeteam/${{ env.APP_NAME }}:latest
odyseeteam/${{ env.APP_NAME }}:${{ env.APP_VERSION }}
file: apps/${{ env.APP_NAME }}/Dockerfile
- name: Deploy watchman
if: env.APP_NAME == 'watchman'
uses: octokit/[email protected]
id: deploy-watchman
env:
GITHUB_TOKEN: ${{ secrets.DEPLOYMENT_REPO_TOKEN }}
with:
route: POST /repos/:repository/dispatches
repository: OdyseeTeam/misc-deployment
event_type: deploy-odysee
client_payload: |
tag: ${{ env.APP_VERSION }}
ref: ${{ github.ref }}
service: ${{ env.APP_NAME }}