From 5ba6b53e738a393a28c647b37064b6f3eada6291 Mon Sep 17 00:00:00 2001 From: lfierz Date: Fri, 10 May 2024 11:21:53 +0200 Subject: [PATCH 1/2] create default driver github workflow --- .github/workflows/github_release.yml | 10 +++ .github/workflows/raspberry_quality_check.yml | 13 +++ .gitlab-ci.yml | 88 ------------------- 3 files changed, 23 insertions(+), 88 deletions(-) create mode 100644 .github/workflows/github_release.yml create mode 100644 .github/workflows/raspberry_quality_check.yml delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/github_release.yml b/.github/workflows/github_release.yml new file mode 100644 index 0000000..d98ee0e --- /dev/null +++ b/.github/workflows/github_release.yml @@ -0,0 +1,10 @@ +name: Github Release + +on: + push: + tags: + - '*' + +jobs: + github-release: + uses: sensirion/.github/.github/workflows/driver.common.github_release.yml@main diff --git a/.github/workflows/raspberry_quality_check.yml b/.github/workflows/raspberry_quality_check.yml new file mode 100644 index 0000000..681a73d --- /dev/null +++ b/.github/workflows/raspberry_quality_check.yml @@ -0,0 +1,13 @@ +name: Quality check + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + driver-quality: + uses: sensirion/.github/.github/workflows/driver.c.check.yml@main diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index b731de4..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,88 +0,0 @@ -stages: - - validate - - build - - -variables: - YQ_URL: https://github.com/mikefarah/yq/releases/download/v4.33.3/yq_linux_amd64 - -metadata_check: - stage: validate - image: - name: registry.gitlab.sensirion.lokal/mso-sw/drivers/docker-driver-generator:0.2.0 - tags: [linux, docker] - before_script: - - apt-get -qq update && apt-get -qq install -y wget - - if ! [ -d downloads/ ]; then mkdir downloads; fi - - if ! [ -e downloads/yq ]; then wget --no-verbose $YQ_URL -O downloads/yq; fi - - cp downloads/yq /usr/local/bin/yq && chmod +x /usr/local/bin/yq - script: - # check if metadata.yml exists - - > - if ! [ -f "metadata.yml" ]; then - echo "metadata.yml file not found" - exit 1 - fi - # check that dg_status is 'released' - - export DG_STATUS=$(yq ".dg_status.[]" ./metadata.yml) - - > - if [ $DG_STATUS != "released" ]; then - echo "dg_status in metadata.yml has to be 'released', not '$DG_STATUS'" - exit 1 - fi - # check that last_generated is not older than timestamp of last non-merge commit (+ 3 minutes) - - export IS_MANUALLY_MODIFIED=$(yq ".is_manually_modified" ./metadata.yml) - - > - if [ $IS_MANUALLY_MODIFIED = false ]; then - export LAST_GENERATED_TS=$(yq ".last_generated" ./metadata.yml) - export LAST_GENERATED_TS_EPOCH=$(date -d "$LAST_GENERATED_TS" +%s) - export LAST_NON_MERGE_COMMIT_TS=$(git log --format=%ad --date=iso-strict --no-merges -1) - export COMMIT_TS_EPOCH=$(date -d "$LAST_NON_MERGE_COMMIT_TS" +%s) - if [ $(($LAST_GENERATED_TS_EPOCH + 180)) -lt $COMMIT_TS_EPOCH ]; then - echo "'last_generated' timestamp in metadata.yml is older than commit timestamp ($LAST_GENERATED_TS vs $LAST_NON_MERGE_COMMIT_TS)" - exit 1 - fi - fi - # check that 'is_manually_modified' is set to true if commit is not from driver generator - - export LAST_NON_MERGE_COMMIT_AUTHOR=$(git log --format=%an --no-merges -1) - - > - if ! [ "$LAST_NON_MERGE_COMMIT_AUTHOR" = "Driver Generator 2" ] && [ "$IS_MANUALLY_MODIFIED" = false ]; then - echo "Last commit is not from Driver Generator. Please update 'is_manually_modified' in metadata.yml" - exit 1 - fi - -syntax_check: - stage: validate - image: - name: registry.gitlab.sensirion.lokal/mso-sw/drivers/docker-driver-generator:0.2.0 - tags: [linux, docker] - script: - - find . -type f -iregex ".*\.\(c\|h\|cpp\|ino\)" -exec clang-format-6.0 -i -style=file {} \; && git diff --exit-code - - -cppcheck: - stage: validate - image: - name: registry.gitlab.sensirion.lokal/mso-sw/drivers/docker-driver-generator:0.2.0 - tags: [linux, docker] - script: - - cppcheck --std=c89 --language=c --error-exitcode=1 --enable=warning,style,performance,portability --suppress=unreadVariable -i sample-implementations/ . - -build: - stage: build - image: - name: sensirion/embedded-ci:2.4.0 - tags: [linux, docker] - script: - - cd example-usage - - make - - - -TODO_check: - stage: validate - image: - name: registry.gitlab.sensirion.lokal/mso-sw/drivers/docker-driver-generator:0.2.0 - tags: [linux, docker] - script: - - '! grep -rnw --exclude=.gitlab-ci.yml --exclude=sensirion_i2c_hal.c --exclude-dir=.git --exclude-dir=sample-implementations . -e "TODO"' From 97116774e308ba12bd3afe418f11553d0e927b86 Mon Sep 17 00:00:00 2001 From: lfierz Date: Fri, 10 May 2024 11:21:54 +0200 Subject: [PATCH 2/2] add comment to metadata --- metadata.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/metadata.yml b/metadata.yml index 08bee5a..b87ca0e 100644 --- a/metadata.yml +++ b/metadata.yml @@ -1,3 +1,4 @@ +# driver generation metadata generator_version: 0.40.0 model_version: 2.1.1 dg_status: