Skip to content

Commit

Permalink
refactor: Monorepo to single repo
Browse files Browse the repository at this point in the history
  • Loading branch information
flemzord committed Sep 26, 2024
1 parent 238ff7f commit d8c14fc
Show file tree
Hide file tree
Showing 25 changed files with 314 additions and 53 deletions.
34 changes: 34 additions & 0 deletions .github/actions/env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Setup Env
description: Setup Env for Linux x64
inputs:
token:
description: 'A Github PAT'
required: true
runs:
using: composite
steps:
- uses: earthly/actions-setup@v1
with:
github-token: ${{ inputs.token }}
version: "latest"
use-cache: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: "NumaryBot"
password: ${{ inputs.token }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: "Put back the git branch into git (Earthly uses it for tagging)"
shell: bash
run: |
branch=""
if [ -n "$GITHUB_HEAD_REF" ]; then
branch="$GITHUB_HEAD_REF"
else
branch="${GITHUB_REF##*/}"
fi
git checkout -b "$branch" || true
29 changes: 29 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 40
labels: [ "dependencies" ]
# Groups are updated together in one pull request
groups:
otel:
patterns:
- "go.opentelemetry.io/otel*"
otel-collector:
patterns:
- "go.opentelemetry.io/collector*"
- "github.com/open-telemetry/o*-collector-contrib/*"
otel-instrumentation:
patterns:
- "go.opentelemetry.io/contrib/instrumentation/*"
go-openapi:
patterns:
- "github.com/go-openapi/*"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels: [ "dependencies" ]
139 changes: 139 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Default
on:
merge_group:
push:
branches:
- main
- releases/*
pull_request:
types: [ assigned, opened, synchronize, reopened, labeled ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
PR:
if: github.event_name == 'pull_request'
name: Check PR Title
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dirty:
runs-on: "ubuntu-latest"
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
with:
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- run: >
earthly
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+pre-commit
env:
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
- name: Get changed files
id: changed-files
shell: bash
run: |
hasChanged=$(git status --porcelain)
if (( $(echo ${#hasChanged}) != 0 )); then
git status
echo "There are changes in the repository"
exit 1
fi
Tests:
runs-on: "ubuntu-latest"
needs:
- Dirty
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
with:
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- run: >
earthly
--no-output
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+tests
env:
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
GoReleaser:
runs-on: "ubuntu-latest"
if: contains(github.event.pull_request.labels.*.name, 'build-images') || github.ref == 'refs/heads/main' || github.event_name == 'merge_group'
needs:
- Dirty
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
with:
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- run: >
earthly
--no-output
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
--secret GITHUB_TOKEN=$GITHUB_TOKEN
--secret FURY_TOKEN=$FURY_TOKEN
--secret GORELEASER_KEY=$GORELEASER_KEY
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+release --mode=ci
env:
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
Deploy:
runs-on: "ubuntu-latest"
if: github.ref == 'refs/heads/main'
environment: staging
needs:
- GoReleaser
- Tests
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
with:
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- name: Tailscale
uses: tailscale/github-action@v2
with:
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:ci
- name: "Deploy in staging"
env:
TAG: ${{ github.sha }}
COMPONENT: orchestration
ARGOCD_REGION_AUTH_TOKEN: ${{ secrets.ARGOCD_REGION_AUTH_TOKEN }}
run: >
earthly
--no-output
--secret AUTH_TOKEN=$ARGOCD_REGION_AUTH_TOKEN
+deploy-staging
--TAG=$TAG
--COMPONENT=$COMPONENT
39 changes: 39 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write

jobs:
GoReleaser:
runs-on: "ubuntu-latest"
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
with:
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- run: >
earthly
--no-output
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
--secret GITHUB_TOKEN=$GITHUB_TOKEN
--secret FURY_TOKEN=$FURY_TOKEN
--secret GORELEASER_KEY=$GORELEASER_KEY
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+release --mode=release
env:
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Add the OpenAPI file to the release assets
run: >
gh release upload ${{github.ref_name}} ./openapi.yaml#openapi.yaml
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 6 additions & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
project_name: orchestration
# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
version: 2
project_name: flows

includes:
- from_file:
path: ./../../.goreleaser.default.yaml
monorepo:
tag_prefix: v
dir: ./
- from_url:
url: https://raw.githubusercontent.com/formancehq/earthly/refs/heads/main/.goreleaser.default.yaml

builds:
- binary: orchestration
Expand Down
31 changes: 15 additions & 16 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
VERSION 0.8

IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core
IMPORT ../.. AS stack
IMPORT ../../releases AS releases
IMPORT .. AS ee
IMPORT github.com/formancehq/earthly:tags/v0.16.2 AS core

FROM core+base-image

sources:
WORKDIR src
COPY --pass-args (releases+sdk-generate/go) /src/releases/sdks/go
WORKDIR /src/ee/orchestration
WORKDIR /src
COPY go.* .
COPY --dir pkg cmd internal .
COPY main.go .
Expand All @@ -21,7 +17,7 @@ generate:
RUN apk update && apk add openjdk11
DO --pass-args core+GO_INSTALL --package=go.uber.org/mock/mockgen@latest
COPY (+sources/*) /src
WORKDIR /src/ee/orchestration
WORKDIR /src
DO --pass-args core+GO_GENERATE
SAVE ARTIFACT internal AS LOCAL internal
SAVE ARTIFACT pkg AS LOCAL pkg
Expand All @@ -30,7 +26,7 @@ generate:
compile:
FROM core+builder-image
COPY (+sources/*) /src
WORKDIR /src/ee/orchestration
WORKDIR /src
ARG VERSION=latest
DO --pass-args core+GO_COMPILE --VERSION=$VERSION

Expand All @@ -46,7 +42,7 @@ build-image:
tests:
FROM core+builder-image
COPY (+sources/*) /src
WORKDIR /src/ee/orchestration
WORKDIR /src
WITH DOCKER --pull=postgres:15-alpine
DO --pass-args core+GO_TESTS
END
Expand All @@ -61,14 +57,14 @@ deploy:
RUN kubectl patch Versions.formance.com default -p "{\"spec\":{\"orchestration\": \"${tag}\"}}" --type=merge

deploy-staging:
BUILD --pass-args stack+deployer-module --MODULE=orchestration
BUILD --pass-args core+deploy-staging

lint:
FROM core+builder-image
COPY (+sources/*) /src
COPY --pass-args +tidy/go.* .
WORKDIR /src/ee/orchestration
DO --pass-args stack+GO_LINT
WORKDIR /src
DO --pass-args core+GO_LINT
SAVE ARTIFACT cmd AS LOCAL cmd
SAVE ARTIFACT internal AS LOCAL internal
SAVE ARTIFACT pkg AS LOCAL pkg
Expand All @@ -84,7 +80,7 @@ openapi:
FROM node:20-alpine
RUN apk update && apk add yq
RUN npm install -g openapi-merge-cli
WORKDIR /src/ee/orchestration
WORKDIR /src
COPY --dir openapi openapi
RUN openapi-merge-cli --config ./openapi/openapi-merge.json
RUN yq -oy ./openapi.json > openapi.yaml
Expand All @@ -93,8 +89,11 @@ openapi:
tidy:
FROM core+builder-image
COPY --pass-args (+sources/src) /src
WORKDIR /src/ee/orchestration
DO --pass-args stack+GO_TIDY
WORKDIR /src
DO --pass-args core+GO_TIDY

release:
BUILD --pass-args stack+goreleaser --path=ee/orchestration
FROM core+builder-image
ARG mode=local
COPY --dir . /src
DO core+GORELEASER --mode=$mode
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
This **Formance Enterprise Edition (EE) supplemental license (this “EE Supplemental License”)** governs the use of this software and documentation (collectively, the “EE Software”) by you and any entity you represent (collectively, “You”). If You have separately entered into the Formance, Inc. Enterprise Agreement (the “Enterprise Agreement”), then this EE Supplemental License hereby incorporates by reference the Enterprise Agreement and modifies the Enterprise Agreement solely to the extent set forth herein. If You have separately entered into the Formance, Inc. Subscription Agreement (the “Subscription Agreement”), then this EE Supplemental License hereby incorporates by reference the Agreement and modifies the Subscription Agreement solely to the extent set forth herein. If You have not entered into either the Enterprise Agreement or the Subscription Agreement, then You may use the EE Software solely as set forth in Section 2 below.

In the event of a direct conflict between the terms of this EE Supplemental License and the terms of the Enterprise Agreement or the Subscription Agreement, as applicable, the terms of this EE Supplemental License will control. Except to the extent modified by this EE Supplemental License, the Enterprise Agreement or the Subscription Agreement, as applicable, remain in full force and effect in accordance with its terms.

**By using the EE Software, You hereby agree to the below terms and conditions.**

1. Notwithstanding any terms to the contrary in the Enterprise Agreement or Subscription Agreement, You may copy, modify and publish patches to the EE Software in a production environment (such copies, “Production Copies,” such modifications, “Production Modifications” and such patches, “Production Patches”) if and only if (a) You have agreed to, and are in full compliance with, the Enterprise Agreement or Subscription Agreement, as applicable, and (b) You have a valid license to the EE Software for the correct number of projects. You agree that Formance and/or its licensors (as applicable) will own all right, title and interest in and to all such Production Copies, Production Modifications and Production Patches. You may display and/or distribute such Production Copies, Production Modifications and Production Patches if and only if (i) You have a valid license to the EE Software for the correct number of projects and (ii) You are in compliance with the Enterprise Agreement or Subscription Agreement, as applicable. You hereby assign to Formance all right, title and interest in and to all Production Copies, Production Modifications and Production Patches, including all intellectual property rights embodied in or related to the foregoing.

2. Notwithstanding the foregoing, You may copy and modify the EE Software solely for development and testing purposes (such copies, “Development Copies” and such modifications, “Development Modifications”) **with or without a license to the EE Software if your use is in compliance with this Section 2**. You agree that Formance and/or its licensors (as applicable) will own all right, title and interest in and to all Development Copies and Development Modifications and You hereby assign to Formance all right, title and interest in and to all Development Copies and Development Modifications, including all intellectual property rights embodied in or related to the foregoing. If You do not have a license to the EE Software, then You further agree as follows:

**Other than as expressly set forth in this Section 2, You may not** (a) copy or modify the EE Software, (b) create derivative works of the EE Software, (c) remove or modify any notice of any patent, copyright, trademark, or other proprietary rights that appear on or in the EE Software, (d) reverse engineer, decompile, translate, disassemble, or discover the source code of all or any portion of the EE Software, (e) publicly display all or any part of the EE Software, (f) distribute, disclose, market, lease, publish, merge, resell, assign, loan, sublicense, rent, or transfer the EE Software to any third party, (g) use the EE Software for any dial-up, remote access, interactive, or other on-line or hosted service, or to provide a service bureau, time share, or other services to third parties, (h) merge the EE Software into another product, (i) disclose the results of any EE Software performance benchmarks or test results to any third party without Formance’s prior written consent, (j) use any trademarks, logos, service marks, trade names of Formance, or any portion thereof, without Formance’s prior written consent, (k) use the EE Software, or any portion thereof, in a manner that does not comply with applicable law, regulations, or governmental orders, or (l) use or store the EE Software on equipment not owned or controlled by Customer.

THE EE SOFTWARE IS PROVIDED ON AN “AS IS” BASIS WITHOUT ANY REPRESENTATIONS, WARRANTIES, COVENANTS, OR CONDITIONS OF ANY KIND (EXPRESS OR IMPLIED, STATUTORY OR OTHERWISE), INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, TITLE, FITNESS FOR A PARTICULAR PURPOSE, OR NONINFRINGEMENT. FURTHER, FORMANCE DOES NOT REPRESENT OR WARRANT THAT (A) THE ACCESS TO OR USE OF THE EE SOFTWARE WILL BE SECURE, TIMELY, UNINTERRUPTED, ERROR-FREE, OR OPERATE IN COMBINATION WITH ANY OTHER HARDWARE, SOFTWARE, SYSTEM, OR DATA, (B) THE EE SOFTWARE WILL MEET YOUR REQUIREMENTS OR EXPECTATIONS, OR OTHERWISE PRODUCE ANY PARTICULAR RESULTS, (C) ERRORS OR DEFECTS WILL BE CORRECTED, PATCHES OR WORKAROUNDS WILL BE PROVIDED, OR FORMANCE WILL DETECT ANY BUG IN THE EE SOFTWARE, (D) THE SOFTWARE IS FREE OF VIRUSES OR OTHER HARMFUL COMPONENTS, OR (E) THIRD-PARTY DISRUPTIONS OR SECURITY BREACHES OF THE EE SOFTWARE WILL BE PREVENTED.

FORMANCE WILL NOT BE LIABLE FOR ANY LOSS OF PROFITS OR ANY INDIRECT, SPECIAL, INCIDENTAL, RELIANCE, OR CONSEQUENTIAL DAMAGES OF ANY KIND, REGARDLESS OF THE FORM OF ACTION, WHETHER IN CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY, OR OTHERWISE, EVEN IF INFORMED OF THE POSSIBILITY OF SUCH DAMAGES IN ADVANCE.

FORMANCE’S ENTIRE LIABILITY TO YOU FOR USE OF THE EE SOFTWARE WILL NOT EXCEED $100.

3. You are not granted any other rights beyond what is expressly stated herein and in the Enterprise Agreement or Subscription Agreement, as applicable.

4. This EE Supplemental License does not apply to Formance software that is distributed as part of the Formance Community Edition (CE) (the “CE Software”).
2 changes: 1 addition & 1 deletion cmd/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/formancehq/orchestration/internal/triggers"

sdk "github.com/formancehq/formance-sdk-go/v2"
sdk "github.com/formancehq/formance-sdk-go/v3"
"github.com/formancehq/go-libs/service"
"github.com/formancehq/orchestration/internal/temporalworker"
"github.com/spf13/cobra"
Expand Down
Loading

0 comments on commit d8c14fc

Please sign in to comment.