Skip to content

Commit e493891

Browse files
BUILD-4567: add cirrus build workflow (#1)
Signed-off-by: Jayadeep Kinavoor Madam <[email protected]>
1 parent d437cf9 commit e493891

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

.cirrus.star

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
load("github.com/SonarSource/cirrus-modules@v2", "load_features")
2+
3+
def main(ctx):
4+
return load_features(ctx)

.cirrus.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
artifactory_build: &artifactory_build
2+
ARTIFACTORY_DEPLOY_USERNAME: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer username]
3+
ARTIFACTORY_DEPLOY_PASSWORD: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer access_token]
4+
5+
artifactory_private: &artifactory_private
6+
ARTIFACTORY_PRIVATE_USERNAME: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader username]
7+
ARTIFACTORY_PRIVATE_PASSWORD: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token]
8+
9+
container_definition: &CONTAINER_DEFINITION
10+
dockerfile: .cirrus/poetry.Dockerfile
11+
cluster_name: ${CIRRUS_CLUSTER_NAME}
12+
region: eu-central-1
13+
namespace: default
14+
builder_image_name: POETRY_VM
15+
builder_role: cirrus-builder
16+
builder_image: docker-builder-v*
17+
builder_instance_type: t3.small
18+
builder_subnet_id: ${CIRRUS_AWS_SUBNET}
19+
20+
only_sonarsource_qa: &ONLY_SONARSOURCE_QA
21+
only_if: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_TAG == "" && ($CIRRUS_PR != "" || $CIRRUS_BRANCH == "master")
22+
23+
env:
24+
CIRRUS_SHELL: bash
25+
ARTIFACTORY_URL: VAULT[development/kv/data/repox data.url]
26+
ARTIFACTORY_DEPLOY_REPO: sonarsource-pypi-public-qa
27+
28+
29+
build_task:
30+
eks_container:
31+
<<: *CONTAINER_DEFINITION
32+
cpu: 2
33+
memory: 2G
34+
env:
35+
<<: *artifactory_build
36+
build_script:
37+
- poetry install
38+
- poetry version $(poetry version -s).${CI_BUILD_NUMBER}
39+
- poetry build
40+
- poetry config repositories.sonarsource https://repox.jfrog.io/artifactory/api/pypi/${ARTIFACTORY_DEPLOY_REPO}
41+
- poetry publish -r sonarsource --username ${ARTIFACTORY_DEPLOY_USERNAME} --password ${ARTIFACTORY_DEPLOY_PASSWORD} --verbose
42+
43+
promote_task:
44+
<<: *ONLY_SONARSOURCE_QA
45+
eks_container:
46+
<<: *CONTAINER_DEFINITION
47+
cpu: 2
48+
memory: 2G
49+
env:
50+
ARTIFACTORY_PROMOTE_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-promoter access_token]
51+
promote_script:
52+
# Temporary hack script until https://sonarsource.atlassian.net/browse/BUILD-4592 is completed
53+
# Artifact is copied to sonarsource-pypi-public-builds repo for testing the release workflow as part of https://sonarsource.atlassian.net/browse/BUILD-4501
54+
- export VERSION=$(poetry version -s).$CI_BUILD_NUMBER
55+
- jfrog config add repox --artifactory-url "$ARTIFACTORY_URL" --access-token "$ARTIFACTORY_PROMOTE_ACCESS_TOKEN"
56+
- jfrog rt cp sonarsource-pypi-public-qa/sonar_dummy_python_oss/$VERSION/ sonarsource-pypi-public-builds/sonar_dummy_python_oss/$VERSION/

.cirrus/poetry.Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ARG CIRRUS_AWS_ACCOUNT=275878209202
2+
FROM ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j17-latest
3+
4+
USER root
5+
6+
ARG SCANNER_VERSION=5.0.1.3006
7+
ARG PYTHON_VERSION=3.12.1
8+
9+
# install required dependencies to build Python from source see: https://devguide.python.org/getting-started/setup-building/#install-dependencies
10+
RUN apt-get update && apt-get install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
11+
RUN curl -O https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz
12+
RUN tar -xf Python-${PYTHON_VERSION}.tar.xz
13+
RUN cd Python-${PYTHON_VERSION} && ./configure && make -s -j 4 && make altinstall
14+
RUN cd /usr/local/bin \
15+
&& ln -s python${PYTHON_VERSION%.*} python \
16+
&& ln -s python${PYTHON_VERSION%.*} python3 \
17+
&& ln -s pip${PYTHON_VERSION%.*} pip \
18+
&& ln -s pip${PYTHON_VERSION%.*} pip3
19+
20+
21+
RUN curl -sSL https://install.python-poetry.org | python3 -
22+
ENV PATH=/root/.local/bin:$PATH

0 commit comments

Comments
 (0)