Support for storing configurations for CI/CD, approval rules, and branch policies in a single .src.ci.yaml file at the repository root will soon be discontinued. Use the separate .sourcecraft/ci.yaml, .sourcecraft/review.yaml, and .sourcecraft/branches.yaml files.
Depending on the settings specified in .sourcecraft/ci.yaml, run a trigger event.
Check the CI/CD process:
Under Code on the repository page, go to CI/CD.
Select a running workflow.
The page that opens will display all workflow tasks, cubes (task steps), as well as statuses and execution results.
Examples
Hello World
Docker
Python
Node.js
Java
# This basic workflow # will help you get started with SourceCraft CI/CD# Configuring a trigger event to execute a workflowon:# Executing a workflow to send changes to the main branch# of the remote repository or creating a pull request to the main branchpull_request:-workflows: [sample-workflow]
filter:source_branches: ["**", "!test**"]
target_branches:"main"push:-workflows: [sample-workflow]
filter:branches: ["main"]
workflows:sample-workflow:tasks:-name:sample-taskcubes:# Starting a set of commands -name:sample-cube1image:docker.io/library/nodescript:-echoHello,world!-name:sample-cube2script:-echoAddothercubestobuild,-echotest,anddeployyourproject.
on:push:-workflows:build-workflowfilter:branches: ["main"]
workflows:build-workflow:tasks:-build-tasktasks:-name:build-taskenv:IMAGE_URI:dockerhub_account/hello-worldcubes:-name:docker-buildscript:-dockerbuild.--fileDockerfile--tag$IMAGE_URI:$(date+%s)# Optional: sending a Docker image to a registry# Provide to the cube the credentials for authentication in the registry,# e.g., DockerHub or Yandex Container Registry# - name: push-dockerhub# env:# USER: username# PAT: personal_access_token# script:# - echo $PAT | docker login --username $USER --password-stdin# - docker push $IMAGE_URI
To test the CI\CD process, send a commit with Dockerfile to the main branch:
Add data specific to testing Python applications to the .gitignore file.
.gitignore example
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# PyPI configuration file
.pypirc
To test the CI\CD process, send a commit with a main.py file to the main branch:
print('Hello SourceCraft')
print('Hello SourceCraft')
for i inrange(10):
print(i)
# input
hi = input()
print(hi)
# This workflow will build a Java project using Mavenon:push:-workflows:publish-package-workflowfilter:branches: ["main"]
workflows:publish-package-workflow:settings:max-cube-duration:10mretry:2tasks:-build-publish-tasktasks:-name:build-publish-taskcubes:-name:setup-jdk-mavenscript:-sudoaptinstallopenjdk-21-jdk-y-sudoaptinstallmaven-y-java--version-mvn--version-name:testscript:-echo'test'-name:packagescript:-mvnpackage# Optional: Export the artifact named# `sourcecraft-sample-maven-1.0-SNAPSHOT.jar` from the target directory.# You can download this artifact from the cube in the CI/CD section#artifacts: # paths:# - target/sourcecraft-sample-maven-1.0-SNAPSHOT.jar
Add data specific to testing Java applications to the .gitignore file.
To test the CI\CD process, send a commit with the following files to the main branch:
pom.xml:
<?xml version="1.0" encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.mycompany.app</groupId><artifactId>sourcecraft-sample-maven</artifactId><version>1.0-SNAPSHOT</version><name>bondarevsky-maven</name><!-- FIXME change it to the project's website --><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.release>17</maven.compiler.release></properties><dependencyManagement><dependencies><dependency><groupId>org.junit</groupId><artifactId>junit-bom</artifactId><version>5.11.0</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><dependencies><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-api</artifactId><scope>test</scope></dependency><!-- Optionally: parameterized tests support --><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-params</artifactId><scope>test</scope></dependency></dependencies><build><pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --><plugins><!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --><plugin><artifactId>maven-clean-plugin</artifactId><version>3.4.0</version></plugin><!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --><plugin><artifactId>maven-resources-plugin</artifactId><version>3.3.1</version></plugin><plugin><artifactId>maven-compiler-plugin</artifactId><version>3.13.0</version></plugin><plugin><artifactId>maven-surefire-plugin</artifactId><version>3.3.0</version></plugin><plugin><artifactId>maven-jar-plugin</artifactId><version>3.4.2</version></plugin><plugin><artifactId>maven-install-plugin</artifactId><version>3.1.2</version></plugin><plugin><artifactId>maven-deploy-plugin</artifactId><version>3.1.2</version></plugin><!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --><plugin><artifactId>maven-site-plugin</artifactId><version>3.12.1</version></plugin><plugin><artifactId>maven-project-info-reports-plugin</artifactId><version>3.6.1</version></plugin></plugins></pluginManagement></build></project>
src/test/java/com/mycompany/app/AppTest.java:
package com.mycompany.app;
importstatic org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
* Unit test for simple App.
*/publicclassAppTest {
/**
* Rigorous Test :-)
*/@TestpublicvoidshouldAnswerWithTrue() {
assertTrue(true);
}
}