From 3bac1b469c74337faacbf7f391e787130a23c08d Mon Sep 17 00:00:00 2001 From: Roger Qiu Date: Sun, 22 May 2022 00:28:31 +1000 Subject: [PATCH] WIP --- .gitlab-ci.yml | 316 ++++++++++++++++++++++++------------------------- 1 file changed, 152 insertions(+), 164 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b1acbb9..441f176 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -39,182 +39,170 @@ stages: image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner -# check:lint: -# stage: check -# needs: [] -# script: -# - > -# nix-shell --run ' -# npm run lint; -# ' -# rules: -# - if: $CI_COMMIT_TAG -# when: manual -# - if: $CI_COMMIT_BRANCH == 'master' -# when: manual -# - when: always +check:lint: + stage: check + needs: [] + script: + - > + nix-shell --run ' + npm run lint; + ' + rules: + - if: $CI_COMMIT_TAG + when: manual + - if: $CI_COMMIT_BRANCH == 'master' + when: manual + - when: always -# check:nix-dry: -# stage: check -# needs: [] -# script: -# - nix-build -v -v --dry-run ./release.nix -# rules: -# - if: $CI_COMMIT_TAG -# when: manual -# - if: $CI_COMMIT_BRANCH == 'master' -# when: manual -# - when: always +check:nix-dry: + stage: check + needs: [] + script: + - nix-build -v -v --dry-run ./release.nix + rules: + - if: $CI_COMMIT_TAG + when: manual + - if: $CI_COMMIT_BRANCH == 'master' + when: manual + - when: always -# check:test: -# stage: check -# needs: [] -# script: -# - > -# nix-shell --run ' -# npm run build --verbose; -# npm test -- --ci; -# ' -# artifacts: -# when: always -# reports: -# junit: -# - ./tmp/junit.xml -# rules: -# - if: $CI_COMMIT_TAG -# when: manual -# - if: $CI_COMMIT_BRANCH == 'master' -# when: manual -# # This job will be overridden by `build:linux` -# - if: $CI_COMMIT_BRANCH == 'staging' -# when: never -# - when: always +check:test: + stage: check + needs: [] + script: + - > + nix-shell --run ' + npm run build --verbose; + npm test -- --ci; + ' + artifacts: + when: always + reports: + junit: + - ./tmp/junit.xml + rules: + - if: $CI_COMMIT_TAG + when: manual + - if: $CI_COMMIT_BRANCH == 'master' + when: manual + # This job will be overridden by `build:linux` + - if: $CI_COMMIT_BRANCH == 'staging' + when: never + - when: always -# build:linux: -# stage: build -# needs: -# - check:lint -# script: -# - > -# nix-shell --run ' -# npm run build --verbose; -# npm test -- --ci; -# ' -# artifacts: -# when: always -# reports: -# junit: -# - ./tmp/junit.xml -# paths: -# - ./prebuilds/ -# rules: -# - if: $CI_COMMIT_TAG -# when: manual -# - if: $CI_COMMIT_BRANCH == 'master' -# when: manual -# - if: $CI_COMMIT_BRANCH == 'staging' +build:linux: + stage: build + needs: + - check:lint + script: + - > + nix-shell --run ' + npm run build --verbose; + npm test -- --ci; + ' + artifacts: + when: always + reports: + junit: + - ./tmp/junit.xml + paths: + - ./prebuilds/ + # Only the build:linux preserves the dist + - ./dist + rules: + - if: $CI_COMMIT_TAG + when: manual + - if: $CI_COMMIT_BRANCH == 'master' + when: manual + - if: $CI_COMMIT_BRANCH == 'staging' -# build:windows: -# stage: build -# needs: -# - check:lint -# tags: -# - windows -# before_script: -# - choco install nodejs --version=16.14.2 -y -# - choco install python --version=3.9.12 -y -# - refreshenv -# script: -# - npm config set msvs_version 2019 -# - npm install --ignore-scripts -# - $env:Path = "$(npm bin);" + $env:Path -# - npm run build --verbose -# - npm test -- --ci -# artifacts: -# when: always -# reports: -# junit: -# - ./tmp/junit.xml -# paths: -# - ./prebuilds/ -# rules: -# - if: $CI_COMMIT_TAG -# when: manual -# - if: $CI_COMMIT_BRANCH == 'master' -# when: manual -# - if: $CI_COMMIT_BRANCH == 'staging' +build:windows: + stage: build + needs: + - check:lint + tags: + - windows + before_script: + - choco install nodejs --version=16.14.2 -y + - choco install python --version=3.9.12 -y + - refreshenv + script: + - npm config set msvs_version 2019 + - npm install --ignore-scripts + - $env:Path = "$(npm bin);" + $env:Path + - npm run build --verbose + - npm test -- --ci + artifacts: + when: always + reports: + junit: + - ./tmp/junit.xml + paths: + - ./prebuilds/ + rules: + - if: $CI_COMMIT_TAG + when: manual + - if: $CI_COMMIT_BRANCH == 'master' + when: manual + - if: $CI_COMMIT_BRANCH == 'staging' -# build:macos: -# stage: build -# needs: -# - check:lint -# tags: -# - shared-macos-amd64 -# image: macos-11-xcode-12 -# variables: -# HOMEBREW_NO_INSTALL_UPGRADE: "true" -# HOMEBREW_NO_INSTALL_CLEANUP: "true" -# before_script: -# - brew install node@16 -# - brew link --overwrite node@16 -# - brew install python@3.9 -# - brew link --overwrite python@3.9 -# - hash -r -# script: -# - npm install --ignore-scripts -# - export PATH="$(npm bin):$PATH" -# - export PREBUILD_ARCH=x64+arm64 -# - npm run build --verbose -# - npm test -- --ci -# artifacts: -# when: always -# reports: -# junit: -# - ./tmp/junit.xml -# paths: -# - ./prebuilds/ -# rules: -# - if: $CI_COMMIT_TAG -# when: manual -# - if: $CI_COMMIT_BRANCH == 'master' -# when: manual -# - if: $CI_COMMIT_BRANCH == 'staging' +build:macos: + stage: build + needs: + - check:lint + tags: + - shared-macos-amd64 + image: macos-11-xcode-12 + variables: + HOMEBREW_NO_INSTALL_UPGRADE: "true" + HOMEBREW_NO_INSTALL_CLEANUP: "true" + before_script: + - brew install node@16 + - brew link --overwrite node@16 + - brew install python@3.9 + - brew link --overwrite python@3.9 + - hash -r + script: + - npm install --ignore-scripts + - export PATH="$(npm bin):$PATH" + - export PREBUILD_ARCH=x64+arm64 + - npm run build --verbose + - npm test -- --ci + artifacts: + when: always + reports: + junit: + - ./tmp/junit.xml + paths: + - ./prebuilds/ + rules: + - if: $CI_COMMIT_TAG + when: manual + - if: $CI_COMMIT_BRANCH == 'master' + when: manual + - if: $CI_COMMIT_BRANCH == 'staging' build:prerelease: stage: build - needs: [] - # needs: - # - build:linux - # - build:windows - # - build:macos + # Needing the build jobs to complete means this only runs as part of staging + needs: + - build:linux + - build:windows + - build:macos + variables: + npm_config_auth: "$NPM_TOKEN" script: - - echo $CI_COMMIT_BRANCH - - echo $CI_COMMIT_TAG - - echo $CI_COMMIT_REF_NAME - - echo $CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME - - echo $CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME - - echo $CI_EXTERNAL_PULL_REQUEST_IID - - echo $CI_PIPELINE_SOURCE - - echo $CI_DEFAULT_BRANCH - # script: - # - > - # nix-shell --run ' - # npm publish --tag $CI_COMMIT_BRANCH --access public; - # ' - # we could use changes on package.json as well but that seems unnecessary + - > + nix-shell --run ' + npm publish --tag staging --access public; + ' rules: - # we only want to allow this... if this tag is pushed in - # and the tag can only be pushed due to a pre-release tag - # generally say this is a prerelease-tag, not prerelease-* or release-* - # but after the builds work, we want to push up to npm - # but we cannot unless we create a change to package.json - # now it will bump up the version... but then the next time it runs the same occurs - # the tag is only created for staging - # note that CI_COMMIT_BRANCH doesn't actually exist in tag pipelines - # so if i push up a tag this won't make any sense - - if: $CI_COMMIT_TAG =~ /^v.+/ + # Only run this for version tags that have pre-release + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-.+/ && $CI_COMMIT_REF_PROTECTED == "true" - when: never +# could we do this based ona a COMMIT on the staging branch +# one that which has a tag? # integration:builds: # stage: integration