-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add initial gitlab-ci.yml * update sync rules * add shellcheck style template * sync to master * switch image to alpine * Update sync to be more generic - control repo with vars * Move sync job to separate file for downstream trigger * fix local * move rules from upstream to downstream * move rules from upstream to downstream * revert rules from child to parent * update defaults * update defaults * Move vars to downstream * streamline rules * add trigger defaults * add trigger defaults * revert default trigger * re-enable manual sync - add allow_failure so it doesn't block the pipeline * streamline vars * try to set default rules * revert rules * revert rules * remove stage * remove manual trigger * streamline test * move variables * Shellcheck doesn't need anything so it can run first * curl checkstyle template * add curl * add insecure curl * debug checkstyle xslt * use wget instead of curl * checkstyle template in yml * update method to dump file * test * fix filename * remove debug * change test to lint stage * remove checkstyle2junit.xslt * Remove wget * rename default rules - use corect branch name - use correct image tag name * update rule names * add push_only rule * move files to .gitlab * update paths * remove unused vars
- Loading branch information
Showing
4 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
include: | ||
- local: .gitlab/defaults.yml | ||
- local: .gitlab/shellcheck.yml | ||
- local: .gitlab/sync-github.yml | ||
|
||
stages: | ||
- lint | ||
- sync | ||
|
||
sync-github: | ||
variables: | ||
GITHUB_REPO: DSS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.default_rules: | ||
merge_only: | ||
- if: $CI_PIPELINE_SOURCE == "merge_request_event" | ||
variables: | ||
BRANCH_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME | ||
SONAR_BRANCH: '' | ||
- if: $CI_PIPELINE_SOURCE == "schedule" | ||
when: never | ||
- if: $CI_PIPELINE_SOURCE == "web" | ||
merge_and_push: | ||
- if: $CI_PIPELINE_SOURCE == "merge_request_event" | ||
variables: | ||
BRANCH_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME | ||
SONAR_BRANCH: '' | ||
- if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "push" | ||
- if: $CI_COMMIT_BRANCH =~ /^stable\/.*/ && $CI_PIPELINE_SOURCE == "push" | ||
- if: $CI_PIPELINE_SOURCE == "schedule" | ||
when: never | ||
- if: $CI_PIPELINE_SOURCE == "web" | ||
push_only: | ||
- if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "push" | ||
- if: $CI_COMMIT_BRANCH =~ /^stable\/.*/ && $CI_PIPELINE_SOURCE == "push" | ||
scheduled_sync: | ||
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULE_TYPE == "sync" | ||
|
||
variables: | ||
BRANCH_NAME: $CI_COMMIT_BRANCH | ||
SONAR_BRANCH: -Dsonar.branch.name=$CI_COMMIT_BRANCH | ||
|
||
default: | ||
image: | ||
name: dss-build_$BRANCH_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
shellcheck: | ||
stage: lint | ||
image: koalaman/shellcheck-alpine:$SHELLCHECK_VER | ||
before_script: | ||
- apk update | ||
- apk add git xmlstarlet | ||
- shellcheck --version | ||
- | | ||
cat > checkstyle2junit.xslt <<EOL | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
<xsl:output encoding="UTF-8" method="xml"></xsl:output> | ||
<xsl:template match="/"> | ||
<testsuite> | ||
<xsl:attribute name="tests"> | ||
<xsl:value-of select="count(.//file)" /> | ||
</xsl:attribute> | ||
<xsl:attribute name="failures"> | ||
<xsl:value-of select="count(.//error)" /> | ||
</xsl:attribute> | ||
<xsl:for-each select="//checkstyle"> | ||
<xsl:apply-templates /> | ||
</xsl:for-each> | ||
</testsuite> | ||
</xsl:template> | ||
<xsl:template match="file"> | ||
<testcase> | ||
<xsl:attribute name="classname"> | ||
<xsl:value-of select="@name" /> | ||
</xsl:attribute> | ||
<xsl:attribute name="name"> | ||
<xsl:value-of select="@name" /> | ||
</xsl:attribute> | ||
<xsl:apply-templates select="node()" /> | ||
</testcase> | ||
</xsl:template> | ||
<xsl:template match="error"> | ||
<failure> | ||
<xsl:attribute name="type"> | ||
<xsl:value-of select="@source" /> | ||
</xsl:attribute> | ||
<xsl:text>Line </xsl:text> | ||
<xsl:value-of select="@line" /> | ||
<xsl:text>: </xsl:text> | ||
<xsl:value-of select="@message" /> | ||
<xsl:text> See https://www.shellcheck.net/wiki/</xsl:text> | ||
<xsl:value-of select="substring(@source, '12')" /> | ||
</failure> | ||
</xsl:template> | ||
</xsl:stylesheet> | ||
EOL | ||
script: | ||
- git ls-files --exclude='*.sh' --ignored -c -z | | ||
xargs -t --no-run-if-empty -0 shellcheck --format=checkstyle | | ||
xmlstarlet tr checkstyle2junit.xslt > | ||
shellcheck.xml | ||
artifacts: | ||
when: always | ||
reports: | ||
junit: shellcheck.xml | ||
variables: | ||
SHELLCHECK_VER: v0.9.0 | ||
needs: [] | ||
rules: | ||
- !reference [.default_rules, merge_and_push] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
sync-github: | ||
stage: sync | ||
image: | ||
name: alpine:3.19.1 | ||
before_script: | ||
- apk add git | ||
- git config --global http.sslVerify false | ||
script: | ||
- mkdir $GITHUB_REPO && cd $GITHUB_REPO | ||
- git clone --branch $GITHUB_BRANCH https://github.com/$GITHUB_PROJECT/$GITHUB_REPO . | ||
- git remote rename origin old-origin | ||
- git remote add origin https://$CI_USERNAME:$CI_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git | ||
- git push origin $GITHUB_BRANCH:$GITLAB_BRANCH | ||
- git push -u origin --tags | ||
variables: | ||
GIT_STRATEGY: none | ||
GITHUB_PROJECT: OpenMPDK | ||
GITHUB_BRANCH: master | ||
GITLAB_BRANCH: master | ||
rules: | ||
- !reference [.default_rules, scheduled_sync] |