|
| 1 | +include: |
| 2 | + - template: Code-Quality.gitlab-ci.yml |
| 3 | + |
| 4 | +code_quality: |
| 5 | + before_script: |
| 6 | + - echo "nothing to do.." |
| 7 | + services: # Shut off Docker-in-Docker |
| 8 | + tags: |
| 9 | + - cq-sans-dind # Set this job to only run on our new specialized runner |
| 10 | + artifacts: |
| 11 | + paths: [gl-code-quality-report.json] |
| 12 | + |
| 13 | +metrics: |
| 14 | + before_script: |
| 15 | + - echo "nothing to do.." |
| 16 | + script: |
| 17 | + - echo 'metric_name metric_value' > metrics.txt |
| 18 | + artifacts: |
| 19 | + reports: |
| 20 | + metrics: metrics.txt |
| 21 | + |
| 22 | +stages: |
| 23 | + - test |
| 24 | + - build |
| 25 | + - publish |
| 26 | + |
| 27 | +precommit: |
| 28 | + image: mcr.microsoft.com/dotnet/sdk:5.0-alpine |
| 29 | + stage: test |
| 30 | + except: |
| 31 | + - public |
| 32 | + before_script: |
| 33 | + - export PYTHONUNBUFFERED=1 |
| 34 | + - apk add --no-cache git build-base python3 python3-dev wget bash nodejs nodejs-npm && ln -sf python3 /usr/bin/python |
| 35 | + - python3 -m ensurepip |
| 36 | + - pip3 install --no-cache --upgrade pip setuptools |
| 37 | + - python3 -m pip install pre-commit |
| 38 | + - rm package-lock.json |
| 39 | + - dotnet restore "web/web.csproj" |
| 40 | + - dotnet --version |
| 41 | + script: |
| 42 | + - export PATH="$PATH:/root/.dotnet/tools" |
| 43 | + - dotnet tool install -g dotnet-format |
| 44 | + - npm -g install |
| 45 | + # - pre-commit run dotnet-format --all-files |
| 46 | + - pre-commit run check-json --all-files |
| 47 | + - pre-commit run check-toml --all-files |
| 48 | + - pre-commit run check-yaml --all-files |
| 49 | + - pre-commit run end-of-file-fixer --all-files |
| 50 | + - pre-commit run isort --all-files |
| 51 | + - pre-commit run black --all-files |
| 52 | + - pre-commit run prettier --all-files |
| 53 | + - pre-commit run stylelint --all-files |
| 54 | + |
| 55 | +build_web: |
| 56 | + image: mcr.microsoft.com/dotnet/sdk:5.0-alpine |
| 57 | + stage: build |
| 58 | + except: |
| 59 | + - public |
| 60 | + script: |
| 61 | + - cd "web" |
| 62 | + - dotnet publish -r win-x86 --self-contained false -c Release -o out |
| 63 | + artifacts: |
| 64 | + paths: ["/builds/atlas/web/atlas-dotnet/web/out/"] |
| 65 | + |
| 66 | +pages: |
| 67 | + image: python:3.9 |
| 68 | + stage: publish |
| 69 | + before_script: |
| 70 | + # need to do installs here cause we don't have a real python package |
| 71 | + - python -m pip install tox poetry Sphinx Pygments furo sphinx-copybutton sphinx-inline-tabs myst-parser colorama sphinx-panels git+https://github.com/sphinx-contrib/youtube.git |
| 72 | + script: |
| 73 | + - tox -e docs |
| 74 | + - mv docs/_build/ public/ |
| 75 | + artifacts: |
| 76 | + paths: |
| 77 | + - public |
| 78 | + only: |
| 79 | + - master |
| 80 | + |
| 81 | +deploy_test: |
| 82 | + image: alpine:latest |
| 83 | + stage: publish |
| 84 | + only: |
| 85 | + - master |
| 86 | + dependencies: |
| 87 | + - build_web |
| 88 | + needs: [build_web] |
| 89 | + before_script: |
| 90 | + - apk add --no-cache openssh |
| 91 | + - eval $(ssh-agent -s) |
| 92 | + - echo "$atlas_ssh_key" | ssh-add - |
| 93 | + - mkdir -p ~/.ssh |
| 94 | + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' |
| 95 | + script: |
| 96 | + # empty folder |
| 97 | + - ssh $atlas_ssh_user@$atlas_server "cd C:\inetpub\wwwroot\atlas-test && DEL /Q . && for /d %x in (C:\inetpub\wwwroot\atlas-test\*) do @rd /s /q \"%x\"" |
| 98 | + # load new site |
| 99 | + - scp -r /builds/atlas/web/atlas-dotnet/web/out/* $atlas_ssh_user@$atlas_server:/c:/inetpub/wwwroot/atlas-test/ |
| 100 | + |
| 101 | + |
| 102 | +public: |
| 103 | + stage: publish |
| 104 | + image: python:3.9 |
| 105 | + needs: |
| 106 | + - job: build_web |
| 107 | + artifacts: false |
| 108 | + only: |
| 109 | + - master |
| 110 | + except: |
| 111 | + - public |
| 112 | + before_script: |
| 113 | + - apt-get install -y git |
| 114 | + - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' |
| 115 | + - eval $(ssh-agent -s) |
| 116 | + - mkdir -p ~/.ssh |
| 117 | + - ssh-keyscan github.com >> ~/.ssh/known_hosts |
| 118 | + - echo "$github_priv_key" | tr -d '\r' | ssh-add - |
| 119 | + - git config --global user.email "$GITLAB_USER_EMAIL" |
| 120 | + - git config --global user.name "$GITLAB_USER_NAME" |
| 121 | + - shopt -s dotglob # include dotfiles in mv |
| 122 | + script: |
| 123 | + - cd public-publish && python build_public.py |
| 124 | + - cd $CI_PROJECT_DIR |
| 125 | + - git init |
| 126 | + - git remote add origin https://oauth2:${CI_PUSH_TOKEN}@$CI_SERVER_HOST/$CI_PROJECT_PATH.git || git remote set-url origin https://oauth2:${CI_PUSH_TOKEN}@$CI_SERVER_HOST/$CI_PROJECT_PATH.git |
| 127 | + - git config user.email "$GITLAB_USER_EMAIL" |
| 128 | + - git config user.name "$GITLAB_USER_NAME" |
| 129 | + - git add . && git commit -m '[skip ci] public update' |
| 130 | + # force to remove history on branch |
| 131 | + - export GIT_SSL_NO_VERIFY=1 && git push --force --follow-tags origin HEAD:public |
| 132 | + # list changes |
| 133 | + - cd ..; rm -rf pub; mkdir pub; cd pub && git init && git remote add origin [email protected]:Riverside-Healthcare/Atlas.git && git pull origin master |
| 134 | + - git rm -rf . ; git clean -fxd # remove pub files, except git |
| 135 | + - cd $CI_PROJECT_DIR && rm -rf .git |
| 136 | + - cd .. && cd pub && mv $CI_PROJECT_DIR/* . |
| 137 | + - git status |
| 138 | + |
| 139 | +github: |
| 140 | + when: manual |
| 141 | + only: |
| 142 | + - public # public branch |
| 143 | + stage: publish |
| 144 | + image: python:3.9 |
| 145 | + before_script: |
| 146 | + - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' |
| 147 | + - eval $(ssh-agent -s) |
| 148 | + - mkdir -p ~/.ssh |
| 149 | + - ssh-keyscan github.com >> ~/.ssh/known_hosts |
| 150 | + - echo "$github_priv_key" | tr -d '\r' | ssh-add - |
| 151 | + - git config --global user.email "$GITLAB_USER_EMAIL" |
| 152 | + - git config --global user.name "$GITLAB_USER_NAME" |
| 153 | + - shopt -s dotglob # include dotfiles in mv |
| 154 | + script: |
| 155 | + - cd ..; rm -rf pub; mkdir pub; cd pub && git init && git remote add origin [email protected]:Riverside-Healthcare/Atlas.git && git pull origin master |
| 156 | + - git rm -rf . ; git clean -fxd # remove pub files, except git |
| 157 | + - cd $CI_PROJECT_DIR && rm -rf .git |
| 158 | + - cd .. && cd pub && mv $CI_PROJECT_DIR/* . |
| 159 | + - git status |
| 160 | + - git add . && git commit -m "$MESSAGE" |
| 161 | + - git status |
| 162 | + - git push -u origin master |
0 commit comments