|
| 1 | +name: Tests, Package, and Deployment |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + branches: [next, qa, main] |
| 8 | + tags: ["v*"] |
| 9 | + |
| 10 | +# cancel previous job if new commit is pushed |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +env: |
| 16 | + PKG_NAME: dgs_resolution |
| 17 | + |
| 18 | +jobs: |
| 19 | + ################# |
| 20 | + ### Run Tests ### |
| 21 | + ################# |
| 22 | + |
| 23 | + # tests: |
| 24 | + # runs-on: ubuntu-latest |
| 25 | + # defaults: |
| 26 | + # run: |
| 27 | + # shell: bash -el {0} |
| 28 | + # steps: |
| 29 | + # - name: Checkout |
| 30 | + # uses: actions/checkout@v6 |
| 31 | + |
| 32 | + # - name: Setup Pixi |
| 33 | + # uses: prefix-dev/setup-pixi@v0.9.4 |
| 34 | + |
| 35 | + # - name: Install chromium |
| 36 | + # run: | |
| 37 | + # echo "chromium enables testing HTML reports" |
| 38 | + # sudo apt-get install --yes chromium-browser |
| 39 | + |
| 40 | + # - name: Run unit tests |
| 41 | + # run: | |
| 42 | + # pixi run test -vv -m "not datarepo and not sns_mounted" --cov=src --cov-report=xml --cov-report=term-missing tests/ |
| 43 | + # mv .coverage .coverage.unit |
| 44 | + |
| 45 | + # - name: Run integration tests |
| 46 | + # run: | |
| 47 | + # git submodule update --init |
| 48 | + # pixi run test -vv -m "datarepo" --cov=src --cov-report=xml --cov-report=term-missing tests/ |
| 49 | + # mv .coverage .coverage.integration |
| 50 | + |
| 51 | + # - name: Upload coverage to codecov |
| 52 | + # uses: codecov/codecov-action@v5 |
| 53 | + # with: |
| 54 | + # token: ${{ secrets.CODECOV_TOKEN }} |
| 55 | + |
| 56 | + ############################## |
| 57 | + ### Package and Deployment ### |
| 58 | + ############################## |
| 59 | + |
| 60 | + build: |
| 61 | + runs-on: ubuntu-latest |
| 62 | + defaults: |
| 63 | + run: |
| 64 | + shell: bash -el {0} |
| 65 | + steps: |
| 66 | + - name: Checkout |
| 67 | + uses: actions/checkout@v6 |
| 68 | + with: |
| 69 | + fetch-depth: 100 |
| 70 | + fetch-tags: true |
| 71 | + ref: ${{ github.ref }} |
| 72 | + |
| 73 | + - name: Setup Pixi |
| 74 | + uses: prefix-dev/setup-pixi@v0.9.4 |
| 75 | + |
| 76 | + - name: Build conda package |
| 77 | + run: | |
| 78 | + pixi run conda-build |
| 79 | + mkdir -p /tmp/local-channel/linux-64 |
| 80 | + cp ${{ env.PKG_NAME }}-*.conda /tmp/local-channel/linux-64/ |
| 81 | +
|
| 82 | + - name: Verify Conda Package |
| 83 | + uses: neutrons/conda-verify@main |
| 84 | + with: |
| 85 | + python-version: "3.11" |
| 86 | + local-channel: /tmp/local-channel |
| 87 | + package-name: ${{ env.PKG_NAME }} |
| 88 | + |
| 89 | + # Upload the conda package for job "publish" to use later |
| 90 | + - name: upload conda package as artifact |
| 91 | + uses: actions/upload-artifact@v6 |
| 92 | + if: startsWith(github.ref, 'refs/tags/v') |
| 93 | + with: |
| 94 | + name: artifact-conda-package |
| 95 | + path: ${{ env.PKG_NAME }}-*.conda |
| 96 | + |
| 97 | + # Publish the package as a separate job so that the Github Actions webpage |
| 98 | + # shows it as a separate step in the CI workflow |
| 99 | + publish: |
| 100 | + runs-on: ubuntu-latest |
| 101 | + needs: [tests, build] |
| 102 | + if: startsWith(github.ref, 'refs/tags/v') |
| 103 | + defaults: |
| 104 | + run: |
| 105 | + shell: bash -el {0} |
| 106 | + steps: |
| 107 | + - name: Checkout |
| 108 | + uses: actions/checkout@v6 |
| 109 | + with: |
| 110 | + fetch-depth: 100 |
| 111 | + fetch-tags: true |
| 112 | + ref: ${{ github.ref }} |
| 113 | + |
| 114 | + - name: Setup Pixi |
| 115 | + uses: prefix-dev/setup-pixi@v0.9.4 |
| 116 | + |
| 117 | + - name: Download conda package artifact |
| 118 | + uses: actions/download-artifact@v7 |
| 119 | + with: |
| 120 | + name: artifact-conda-package |
| 121 | + |
| 122 | + - name: Upload package to anaconda |
| 123 | + env: |
| 124 | + ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }} |
| 125 | + IS_RC: ${{ contains(github.ref, 'rc') }} |
| 126 | + run: | |
| 127 | + # label is main or rc depending on the tag-name |
| 128 | + CONDA_LABEL="main" |
| 129 | + if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi |
| 130 | + echo pushing ${{ github.ref }} with label $CONDA_LABEL |
| 131 | + pixi run anaconda upload --label $CONDA_LABEL --user neutrons ${{ env.PKG_NAME }}-*.conda |
| 132 | +
|
| 133 | + # Trigger GitLab dev deploy pipeline |
| 134 | + deploy-dev: |
| 135 | + runs-on: ubuntu-latest |
| 136 | + needs: build |
| 137 | + if: github.ref == 'refs/heads/next' |
| 138 | + steps: |
| 139 | + - name: Get Environment Name |
| 140 | + uses: neutrons/branch-mapper@main |
| 141 | + id: env_name |
| 142 | + with: |
| 143 | + prefix: mr_reduction |
| 144 | + |
| 145 | + - name: Trigger Dev Deploy |
| 146 | + # use https://github.com/eic/trigger-gitlab-ci/pull/14 until merged |
| 147 | + uses: eic/trigger-gitlab-ci@d984d8d53d871d2fdc1325639d94322da6e8747f |
| 148 | + id: trigger |
| 149 | + with: |
| 150 | + url: https://code.ornl.gov |
| 151 | + project_id: 20403 |
| 152 | + ref_name: main |
| 153 | + token: ${{ secrets.GITLAB_DEPLOY_TOKEN }} |
| 154 | + |
| 155 | + - name: Annotate commit |
| 156 | + uses: peter-evans/commit-comment@v4 |
| 157 | + with: |
| 158 | + body: | |
| 159 | + GitLab pipeline for ${{ steps.env_name.outputs.name }} has been submitted for this commit: ${{ steps.trigger.outputs.web_url }} |
0 commit comments