Skip to content
This repository was archived by the owner on May 19, 2026. It is now read-only.

If two scheduler loop are running concurrently, it can happen that av… #334

If two scheduler loop are running concurrently, it can happen that av…

If two scheduler loop are running concurrently, it can happen that av… #334

Workflow file for this run

name: Deploy
on:
push:
branches:
- staging
pull_request:
branches:
- staging
workflow_dispatch:
env:
REGISTRY: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s
IMAGE: riscv-runner
PROD_URL: https://riseriscvrunnerappqdvknz9s-ghfe.functions.fnc.fr-par.scw.cloud
STAGING_URL: https://riseriscvrunnerappst73ndwr0w-ghfe.functions.fnc.fr-par.scw.cloud
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0 # diff-cover needs the base commit
- name: Setup Python 3.12
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"
- name: Run tests
run: |
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r container/requirements.txt
pip install -r requirements-dev.txt
PYTHONPATH=${{ github.workspace }}/container pytest
- name: Add diff coverage to step summary
if: github.event_name == 'pull_request' || github.event_name == 'push'
run: |
if [[ "${{ github.event_name }}" = "pull_request" ]]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
BASE_REF_NAME="refs/heads/${{ github.event.pull_request.base.ref }}"
BASE_REF_URL="${{ github.event.pull_request.base.repo.html_url }}/tree/${BASE_SHA}"
elif [[ "${{ github.event_name }}" = "push" ]]; then
if [[ "${{ github.ref_name == github.event.repository.default_branch }}" = "true" ]]; then
# If we are on default branch
if [[ "${{ github.event.forced }}" = "true" ]]; then
# If we are force-pushing, we don't know what's the previous commit to compare to
echo "::error::.github/workflows/release.yml Branch ${{ github.ref_name}} was just force-pushed, can't measure diff-coverage"
exit 0 # do not fail the workflow nonetheless
fi
BASE_SHA="${{ github.event.before }}"
BASE_REF_NAME="${{ github.ref }}"
else
# If we are not on default branch, compare to default branch
git fetch origin ${{ github.event.repository.default_branch }}
BASE_SHA="$(git rev-parse origin/${{ github.event.repository.default_branch }})"
BASE_REF_NAME="${{ github.event.repository.default_branch }}"
fi
BASE_REF_URL="${{ github.event.repository.html_url }}/tree/${BASE_SHA}"
fi
if [[ -n "${BASE_SHA}" ]]; then
source .venv/bin/activate
diff-cover coverage.xml \
--compare-branch "${BASE_SHA}" \
--markdown-report diff-cover.md \
--fail-under 80
{
echo ""
echo "**Base ref: [${BASE_REF_NAME}](${BASE_REF_URL})**"
echo ""
cat diff-cover.md
} >> "$GITHUB_STEP_SUMMARY"
fi
build:
needs: [test]
runs-on: ubuntu-latest
outputs:
ghfe-digest: ${{ steps.ghfe.outputs.digest }}
scheduler-digest: ${{ steps.scheduler.outputs.digest }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: rlespinasse/github-slug-action@9e7def61550737ba68c62d34a32dd31792e3f429 # v5.5.0
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to Container Registry
if: github.repository_owner == 'riseproject-dev'
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ${{ env.REGISTRY }}
username: nologin
password: ${{ secrets.SCW_SECRET_KEY }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
- name: Build ghfe image
id: ghfe
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
platforms: linux/amd64
context: container
file: container/Dockerfile
target: ghfe
tags: ${{ env.REGISTRY }}/${{ env.IMAGE }}:ghfe-sha-${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha,scope=docker
cache-to: |
${{ github.ref_name == github.event.repository.default_branch && 'type=gha,scope=type=gha,scope=docker' || '' }}
push: ${{ github.repository_owner == 'riseproject-dev' }}
- name: Build scheduler image
id: scheduler
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
platforms: linux/amd64
context: container
file: container/Dockerfile
target: scheduler
tags: ${{ env.REGISTRY }}/${{ env.IMAGE }}:scheduler-sha-${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha,scope=docker
cache-to: |
${{ github.ref_name == github.event.repository.default_branch && 'type=gha,scope=type=gha,scope=docker' || '' }}
push: ${{ github.repository_owner == 'riseproject-dev' }}
deploy-staging:
if: github.repository_owner == 'riseproject-dev' && github.ref_name == github.event.repository.default_branch
name: "deploy to staging"
needs: [build]
runs-on: ubuntu-latest
environment: staging
concurrency:
group: deploy-staging
cancel-in-progress: false
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ${{ env.REGISTRY }}
username: nologin
password: ${{ secrets.SCW_SECRET_KEY }}
- name: Tag ghfe image for staging
run: >-
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE }}:ghfe-staging \
${{ env.REGISTRY }}/${{ env.IMAGE }}@${{ needs.build.outputs.ghfe-digest }}
- name: Tag scheduler image for staging
run: >-
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE }}:scheduler-staging \
${{ env.REGISTRY }}/${{ env.IMAGE }}@${{ needs.build.outputs.scheduler-digest }}
- name: Deploy to Scaleway
run: npm ci && npx serverless@3 deploy --stage=staging
env:
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
GHAPP_WEBHOOK_SECRET: ${{ secrets.GHAPP_WEBHOOK_SECRET }}
GHAPP_ORG_PRIVATE_KEY: ${{ secrets.GHAPP_ORG_PRIVATE_KEY }}
GHAPP_PERSONAL_PRIVATE_KEY: ${{ secrets.GHAPP_PERSONAL_PRIVATE_KEY }}
K8S_KUBECONFIG: ${{ secrets.K8S_KUBECONFIG }}
POSTGRES_URL: ${{ secrets.POSTGRES_URL }}
- name: Health check
run: python3 ./bin/check-health.py --staging
- name: Trigger sample workflow
env:
GH_TOKEN: ${{ secrets.RISCV_RUNNER_SAMPLE_ACCESS_TOKEN }}
GH_REPO: riseproject-dev/riscv-runner-sample
GH_WORKFLOW: hello.yml
run: |
gh workflow run ${GH_WORKFLOW} --repo ${GH_REPO}
sleep 5
gh run watch $(gh run list --repo ${GH_REPO} --workflow ${GH_WORKFLOW} --limit 1 --json databaseId --jq '.[0].databaseId') --repo ${GH_REPO} --interval 15 --exit-status
deploy-prod:
if: github.repository_owner == 'riseproject-dev' && github.ref_name == github.event.repository.default_branch
name: "deploy to prod"
needs: [build, deploy-staging]
runs-on: ubuntu-latest
environment: prod
concurrency:
group: deploy-prod
cancel-in-progress: false
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ${{ env.REGISTRY }}
username: nologin
password: ${{ secrets.SCW_SECRET_KEY }}
- name: Tag ghfe image for prod
run: >-
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE }}:ghfe-prod \
${{ env.REGISTRY }}/${{ env.IMAGE }}@${{ needs.build.outputs.ghfe-digest }}
- name: Tag scheduler image for prod
run: >-
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE }}:scheduler-prod \
${{ env.REGISTRY }}/${{ env.IMAGE }}@${{ needs.build.outputs.scheduler-digest }}
- name: Deploy to Scaleway
run: npm ci && npx serverless@3 deploy --stage=main
env:
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
GHAPP_WEBHOOK_SECRET: ${{ secrets.GHAPP_WEBHOOK_SECRET }}
GHAPP_ORG_PRIVATE_KEY: ${{ secrets.GHAPP_ORG_PRIVATE_KEY }}
GHAPP_PERSONAL_PRIVATE_KEY: ${{ secrets.GHAPP_PERSONAL_PRIVATE_KEY }}
K8S_KUBECONFIG: ${{ secrets.K8S_KUBECONFIG }}
POSTGRES_URL: ${{ secrets.POSTGRES_URL }}
- name: Health check
run: python3 ./bin/check-health.py