Skip to content

Commit

Permalink
wip: copy chart
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ragot committed Oct 9, 2024
1 parent e0764a7 commit 015fa90
Show file tree
Hide file tree
Showing 118 changed files with 8,032 additions and 677 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[Earthfile]
end_of_line = lf
charset = utf-8
indent_style = space
indent_size = 2

[*.tpl]
end_of_line = lf
charset = utf-8
indent_style = space
indent_size = 2

[*.{yaml,yml}]
end_of_line = lf
charset = utf-8
indent_style = space
indent_size = 2
15 changes: 15 additions & 0 deletions .github/actions/earthly/base/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Base
description: Base Earthly action
runs:
using: composite
steps:
- shell: bash
name: Put back the git branch into git (Earthly uses it for tagging)
run: |
branch=""
if [ -n "$GITHUB_HEAD_REF" ]; then
branch="$GITHUB_HEAD_REF"
else
branch="${GITHUB_REF##*/}"
fi
git checkout -b "$branch" || true
11 changes: 11 additions & 0 deletions .github/actions/earthly/pre-commit/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Pre-Commit
description: Run pre-commit checks with Earthly
runs:
using: composite
steps:
- name: Base Earthly action
uses: ./.github/actions/earthly/base
- name: PreCommit
shell: bash
run: >
earthly +pre-commit
15 changes: 15 additions & 0 deletions .github/actions/github/dirty/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Dirty
description: Check if the current state is dirty
runs:
using: composite
steps:
- 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
26 changes: 26 additions & 0 deletions .github/actions/helm/anychart/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
inputs:
CHART_NAME:
required: true
description: "Name of the chart to package"
CHART_DIR:
required: true
description: "Path to the chart to package"
default: ".helm"

name: AnyChart
description: AnyChart workflow

runs:
using: composite
steps:
- name: Validate
uses: ./.github/actions/helm/validate
with:
CHART_PATH: ./${{ inputs.CHART_DIR }}/${{ inputs.CHART_NAME }}
- name: Dirty
uses: ./.github/actions/github/dirty
- name: Package
uses: ./.github/actions/helm/package
with:
CHART_NAME: ${{ inputs.CHART_NAME }}
CHART_PATH: ./${{ inputs.CHART_DIR }}/${{ inputs.CHART_NAME }}
29 changes: 29 additions & 0 deletions .github/actions/helm/package/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
inputs:
CHART_PATH:
description: "Path to the chart to package"
required: true
CHART_NAME:
description: "Name of the chart to package"
required: true

name: Package
description: Package a chart
runs:
using: composite
steps:
- name: Base Earthly action
uses: ./.github/actions/earthly/base
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- name: Package
shell: bash
env:
CHART_PATH: ${{ inputs.CHART_PATH }}
run: >
earthly $CHART_PATH+package
- name: Archive chart
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.CHART_NAME }}_${{ github.ref_type == 'branch' && github.sha || github.ref_name }}.tgz
path: ${{ inputs.CHART_PATH }}/*.tgz
29 changes: 29 additions & 0 deletions .github/actions/helm/publish/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
inputs:
GH_TOKEN:
description: "Github token to access the ghcr registry"
required: true
CHART_PATH:
description: "Path to the chart to publish"
required: true

name: Publish
description: Publish a chart
runs:
using: composite
steps:
- name: Base Earthly action
uses: ./.github/actions/earthly/base
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- name: Publish
shell: bash
run: >
earthly
--no-output
--allow-privileged
--secret GITHUB_TOKEN=$GH_TOKEN
$CHART_PATH+publish
env:
GH_TOKEN: ${{ inputs.GH_TOKEN }}
CHART_PATH: ${{ inputs.CHART_PATH }}
21 changes: 21 additions & 0 deletions .github/actions/helm/validate/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
inputs:
CHART_PATH:
description: "Path to the chart to package"
required: true

name: Validate
description: Validate a chart
runs:
using: composite
steps:
- name: Base Earthly action
uses: ./.github/actions/earthly/base
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- name: Validate
shell: bash
run: >
earthly $CHART_PATH+validate
env:
CHART_PATH: ${{ inputs.CHART_PATH }}
12 changes: 12 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
docs:
- changed-files:
- any-glob-to-any-file: "**/*.md"

feature:
- head-branch: ["^feat", "feat"]

bug:
- head-branch: ["^fix", "fix"]

release:
- base-branch: "main"
38 changes: 38 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Dependencies"
on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
dependencies:
name: Update Dependencies
runs-on: formance-runner
strategy:
matrix:
chart: ["membership"]
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Update Dependencies
run: earthly ./charts/${{ matrix.chart }}+dependencies

- name: Increment version
run: earthly ./charts/+increment-version --CHART $${{ matrix.chart }}

- uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: chore/dependencies-${{matrix.chart}}-${{ github.sha }}
commit_message: "chore(dependencies): update dependencies for ${{ matrix.chart }}"

# - name: this need to create a pull request with all the changed files
# - name: Create Pull Request
# uses: peter-evans/create-pull-request@v7
50 changes: 50 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Pull Request Labeler"
on:
pull_request:
types: [ assigned, opened, synchronize, reopened, labeled, unlabeled ]

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

jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: formance-runner
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- uses: actions/labeler@v5
with:
sync-labels: true
- name: Retrieve chart changes
id: chart_changes
run: |
CHARTS=$(git diff origin/main --stat | grep -oE 'charts/[^/]+/' | sed 's|charts/||;s|/||' | sort -u | jq -R -s -c 'split("\n") | map(select(. != ""))')
echo "Changed charts: $CHARTS"
echo "::set-output name=changed_charts::$CHARTS"
- name: Label PR based on chart changes
if: steps.chart_changes.outputs.changed_charts != ''
uses: actions/github-script@v7
env:
CHARTS: ${{ steps.chart_changes.outputs.changed_charts }}
with:
script: |
const charts = JSON.parse(process.env.CHARTS);
const labels = charts.map(chart => `chart-${chart.trim()}`).filter(label => label.length > 0);
if (labels.length > 0) {
console.log(`Applying labels: ${labels.join(', ')}`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labels
});
} else {
console.log('No charts changed, skipping labeling.');
}
55 changes: 0 additions & 55 deletions .github/workflows/main.yaml

This file was deleted.

Loading

0 comments on commit 015fa90

Please sign in to comment.