Reusable Workflows
Make sure you previously read CI/CD with Mélodium.
Open-source project? The open-source plan is free, and makes your runs public, ready to link from pull requests and your README.
Reusable Workflow
GitHub Actions reusable workflows are available to run Mélodium within GitHub runners: Mélodium Reusable Workflows . Each workflow version matches a Mélodium version: use @v0.11.0 for Mélodium 0.11.
Every workflow takes the same secrets:
github-token: used to check out the repository, and given to the engine as theMELODIUM_SECRET_GITHUB_TOKENsecret, which is where the status reporting below reads it by default;melodium-api-token: your Cadence.CI run token, given to the engine asMELODIUM_API_TOKENfor--api-reportand for starting machines in your cloud account.
Mélodium on GitHub Actions
The configuration to add in GitHub YAML is:
jobs:
melodium:
uses: melodium-tech/github-actions/.github/workflows/melodium.yml@v0.11.0
permissions:
contents: read
statuses: write
with:
command: run --api-report --logs logs/melodium.log .melodium-ci/Compo.toml --repository_clone_url "${{ github.repositoryUrl }}" --repository_clone_ref "${{ github.ref_name }}" --on_github true --ci_service_project "${{ github.repository }}" --ci_service_sha "${{ github.sha }}"
artifact-path: 'logs/'
secrets:
github-token: ${{ github.token }}
melodium-api-token: ${{ secrets.MELODIUM_API_TOKEN }}The statuses: write permission lets the pipeline report a status on the commit; it can be left out if you don’t. The logs written to logs/ are uploaded as the job’s artifact.
Refer to melodium.yml for the full list of input parameters.
Dispatch Work Within GA Runner
A reusable workflow to run Mélodium with local distribution is available. Steps then run as containers on the GitHub runner itself, instead of machines in your cloud account:
jobs:
melodium:
uses: melodium-tech/github-actions/.github/workflows/melodium-local-distrib.yml@v0.11.0
permissions:
contents: read
statuses: write
with:
command: run --api-report --logs logs/melodium.log .melodium-ci/Compo.toml --work_location compose --repository_clone_url "${{ github.repositoryUrl }}" --repository_clone_ref "${{ github.ref_name }}" --on_github true --ci_service_project "${{ github.repository }}" --ci_service_sha "${{ github.sha }}"
artifact-path: 'logs/'
secrets:
github-token: ${{ github.token }}
melodium-api-token: ${{ secrets.MELODIUM_API_TOKEN }}The run is still reported to Cadence.CI; drop --api-report and the melodium-api-token secret to run without it.
Refer to melodium-local-distrib.yml for the full list of input parameters.
Windows Runner
A reusable workflow to run Mélodium on a Windows runner is available:
jobs:
melodium:
uses: melodium-tech/github-actions/.github/workflows/melodium-windows.yml@v0.11.0
permissions:
contents: read
statuses: write
with:
command: run --api-report --logs logs/melodium.log .melodium-ci/Compo.toml --repository_clone_url "${{ github.repositoryUrl }}" --repository_clone_ref "${{ github.ref_name }}" --on_github true --ci_service_project "${{ github.repository }}" --ci_service_sha "${{ github.sha }}"
artifact-path: 'logs/'
secrets:
github-token: ${{ github.token }}
melodium-api-token: ${{ secrets.MELODIUM_API_TOKEN }}Refer to melodium-windows.yml for the full list of input parameters.
Mac OS Runner
A reusable workflow to run Mélodium on a Mac OS runner is available:
jobs:
melodium:
uses: melodium-tech/github-actions/.github/workflows/melodium-macos.yml@v0.11.0
permissions:
contents: read
statuses: write
with:
command: run --api-report --logs logs/melodium.log .melodium-ci/Compo.toml --repository_clone_url "${{ github.repositoryUrl }}" --repository_clone_ref "${{ github.ref_name }}" --on_github true --ci_service_project "${{ github.repository }}" --ci_service_sha "${{ github.sha }}"
artifact-path: 'logs/'
secrets:
github-token: ${{ github.token }}
melodium-api-token: ${{ secrets.MELODIUM_API_TOKEN }}Refer to melodium-macos.yml for the full list of input parameters.
Report a Status to GitHub
To report commit statuses to GitHub, different methods are available. They all take the GitHub token as a Secret, read by default from env:MELODIUM_SECRET_GITHUB_TOKEN: the token never appears in logs, debug events or what Cadence.CI receives.
Using simpleStep
In a simpleStep treatment, add the parameters as follows.
simpleStep[dispatcher=cicd](
/* … */
github=true,
github_project=/* GitHub project, as owner/name */,
github_sha=/* Commit SHA related to the step */
)The token comes from github_token, which defaults to "env:MELODIUM_SECRET_GITHUB_TOKEN"; set it only to read the token from somewhere else.
The CI/CD template receives these values in its main treatment parameters but does not pass them to its steps: to report statuses, add them to build and test in main:
build: simpleStep[dispatcher=cicd](
/* … */
github=on_github,
github_project=ci_service_project,
github_sha=ci_service_sha
)
/*
…
*/
test: simpleStepWithInput[dispatcher=cicd](
/* … */
github=on_github,
github_project=ci_service_project,
github_sha=ci_service_sha
)Using postGithubState
Within the appropriate treatment, add the postGithubState treatment.
use cicd/services/github::|success
use cicd/services/github::postGithubState
/*
…
*/
treatment someStuff[cicd: CicdDispatchEngine](
// Add the following parameters
github_project: string,
github_sha: string
)
// …
{
/*
…
*/
postSuccess: postGithubState(
name="Doing a treatment",
description="Treatment accomplishing some stuff",
state=|success(),
project=github_project,
sha=github_sha,
token="env:MELODIUM_SECRET_GITHUB_TOKEN"
)
theTreatment.completed -> postSuccess.trigger
}There also exists a more generic setServiceState treatment with prepared triggers for each state. All its inputs must be connected; a step that is never canceled can feed canceled with a closeBlock, which closes without sending anything:
use cicd/services::setServiceState
use std/flow::closeBlock
/*
…
*/
treatment someStuff[cicd: CicdDispatchEngine](
// Add the following parameters
github_project: string,
github_sha: string
)
// …
{
/*
…
*/
setServiceState(
name="Doing a treatment",
description="Treatment accomplishing some stuff",
github=true,
github_project=github_project,
github_sha=github_sha
)
noCancel: closeBlock<void>()
Self.trigger -----------> setServiceState.pending
theTreatment.started ---> setServiceState.running
theTreatment.success ---> setServiceState.success
theTreatment.error -----> setServiceState.error
theTreatment.failed ----> setServiceState.failed
Self.trigger -> noCancel.trigger,closed -> setServiceState.canceled
}Setup Variables
In GitHub, within Settings > Secrets and variables > Actions, in the section Repository secrets, add MELODIUM_API_TOKEN with a run token created in the Cadence.CI dashboard.
The GitHub token needs no setup: ${{ github.token }} is provided by GitHub Actions for each job, with the permissions listed in the job’s permissions.
To give other secrets to the pipeline, pass them to the workflow as secret-1 to secret-10: the engine reads them as env:MELODIUM_SECRET_1 to env:MELODIUM_SECRET_10. Secrets stored on Cadence.CI are read by the steps the pipeline dispatches, given to them by reference.