Commit a3f47c35 authored by Wohlgemuth, Jason's avatar Wohlgemuth, Jason
Browse files

fix(ci): Update CI config and makefile tasks

parent 8f750a0f
Loading
Loading
Loading
Loading
+22 −41
Original line number Diff line number Diff line
default:
  tags:
    - cpu
  image: rust:bookworm
  before_script:
    - apt-get update && apt-get install -y libssl-dev pkg-config musl-tools
    - rustup component add clippy
    - rustup component add rustfmt
    - rustup target add x86_64-unknown-linux-musl

variables:
  BINARY_NAME: xylem
  CHANGELOG: https://code.ornl.gov/research-enablement/xylem/-/blob/main/CHANGELOG.md
  USER: CI
  EMAIL: $GITLAB_USER_EMAIL
  CI_DEBUG_SERVICES: true
  IS_VERSION_TAGGED: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/'

stages:
  - prepare
@@ -25,26 +16,30 @@ stages:
prepare-environment:
  stage: prepare
  image: ubuntu
  tags:
    - cpu
  inherit:
    default: false
    variables: false
  rules:
    - if: $CI_COMMIT_TAG
      when: never
    - if: $CI_COMMIT_TAG != null && $IS_VERSION_TAGGED
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      changes:
        - Cargo.toml
  script:
    - echo "PKG_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' Cargo.toml)" >> variables.env
    - echo "PKG_REGISTRY_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic" >> variables.env
    - echo $PKG_VERSION
    - echo "DEFAULT_TARGET=$(awk -F ' = ' '$1 ~ /default-target/ { gsub(/["]/, "", $2); printf("%s",$2) }' Cargo.toml | tr . _)" >> variables.env
    - echo "DEFAULT_WINDOWS_TARGET=$(awk -F ' *= *' '$1=="DEFAULT_WINDOWS_TARGET"{ sub(/\r$/,"",$2); print $2; exit }' Makefile)" >> variables.env
  artifacts:
    reports:
      dotenv: variables.env

test:
  stage: test
  image: rust
  image: savannah.ornl.gov/research-enablement/acorn/rust:latest
  tags:
    - cpu
  inherit:
    default: true
    variables: true
  rules:
    - if: $CI_COMMIT_TAG
@@ -59,9 +54,10 @@ test:

build-release:
  stage: build
  image: rust
  image: savannah.ornl.gov/research-enablement/acorn/rust:latest
  tags:
    - cpu
  inherit:
    default: true
    variables: true
  needs:
    - job: test
@@ -101,14 +97,17 @@ publish-release-linux:
    ref: "$CI_COMMIT_SHA"
    assets:
      links:
        - name: "${BINARY_NAME} v$PKG_VERSION"
          url: "${PKG_REGISTRY_URL}/x86_64-unknown-linux-musl/v${PKG_VERSION}/${BINARY_NAME}"
        - name: "${BINARY_NAME} v${PKG_VERSION} (Linux)"
          url: "${PKG_REGISTRY_URL}/${DEFAULT_TARGET}/v${PKG_VERSION}/${BINARY_NAME}"
        - name: "${BINARY_NAME} v${PKG_VERSION} (Windows)"
          url: "${PKG_REGISTRY_URL}/${DEFAULT_WINDOWS_TARGET}/v${PKG_VERSION}/${BINARY_NAME}.exe"

upload-binaries:
  stage: release
  image: curlimages/curl:latest
  tags:
    - cpu
  inherit:
    default: false
    variables: true
  needs:
    - job: prepare-environment
@@ -124,24 +123,6 @@ upload-binaries:
        - Cargo.toml
  script:
    - ls -la bin/
    - 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${BINARY_NAME}-v${PKG_VERSION} ${PKG_REGISTRY_URL}/x86_64-unknown-linux-musl/v${PKG_VERSION}/${BINARY_NAME}'
    - 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${BINARY_NAME}-v${PKG_VERSION} ${PKG_REGISTRY_URL}/${DEFAULT_TARGET}/v${PKG_VERSION}/${BINARY_NAME}'
    - 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${BINARY_NAME}-v${PKG_VERSION}.exe ${PKG_REGISTRY_URL}/${DEFAULT_WINDOWS_TARGET}/v${PKG_VERSION}/${BINARY_NAME}.exe'
publish-docs:
  stage: docs
  image: rust
  inherit:
    default: false
    variables: true
  rules:
    - if: $CI_COMMIT_TAG
      when: never
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      changes:
        - ${BINARY_NAME}-cli/**/*.rs
        - ${BINARY_NAME}-lib/**/*.rs
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: manual
  script:
    - git config --global user.name "${USER}"
    - git config --global user.email "${EMAIL}"
    - make publish-docs
+14 −21
Original line number Diff line number Diff line
@@ -43,28 +43,18 @@ lint:
test:
	@cargo nextest run

test-all:
	@cargo nextest run --run-ignored all

test-ci: clean lint
	@cargo test --lib --bins --tests

test-cross: clean
	@for target in $(TARGETS) ; do \
        cross test --target $$target; \
    done

doc:
	@cargo clean --doc
	@cargo doc --no-deps --all-features

build-cross: clean
	@mkdir -p ./bin
	@for target in $(TARGETS) ; do \
		export DISPLAY=:0; \
        cross build --release --target $$target; \
		mv target/$${target}/release/xylem ./bin/xylem_v$(VERSION)_$${target}; \
    done

release: clean
	@echo "Under Construction"
doctest:
	@cargo test --doc

version: 
	@echo $(VERSION)
@@ -94,15 +84,18 @@ TARGETS = \
	arm-unknown-linux-musleabi \
	riscv64gc-unknown-linux-gnu \
	x86_64-unknown-linux-gnu \
	x86_64-unknown-linux-musl
	x86_64-unknown-linux-musl \
	x86_64-pc-windows-gnu
TASKS = \
	audit \
	book \
	build \
	changelog \
	clean \
	coverage \
	doc \
	lint \
	setup \
	test \
	test-ci \
	test-cross \
	doc \
	build \
	build-cross \
	release \
	version
 No newline at end of file