|
| 1 | +# The `spack` group and its projects on gitlab.staging.spack.io. These were |
| 2 | +# originally created by hand, so the `import` blocks below adopt the existing |
| 3 | +# objects rather than creating new ones. |
| 4 | +# |
| 5 | +# Note that the equivalent objects on gitlab.spack.io are still unmanaged; the |
| 6 | +# spack_gitlab module reads them through `data` blocks instead. |
| 7 | + |
| 8 | +resource "gitlab_group" "spack" { |
| 9 | + name = "spack" |
| 10 | + path = "spack" |
| 11 | + |
| 12 | + visibility_level = "public" |
| 13 | +} |
| 14 | + |
| 15 | +import { |
| 16 | + to = gitlab_group.spack |
| 17 | + id = "spack" |
| 18 | +} |
| 19 | + |
| 20 | +resource "gitlab_project" "spack" { |
| 21 | + name = "spack" |
| 22 | + path = "spack" |
| 23 | + namespace_id = gitlab_group.spack.id |
| 24 | + |
| 25 | + visibility_level = "public" |
| 26 | + default_branch = "develop" |
| 27 | + ci_config_path = "share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml" |
| 28 | +} |
| 29 | + |
| 30 | +import { |
| 31 | + to = gitlab_project.spack |
| 32 | + id = "spack/spack" |
| 33 | +} |
| 34 | + |
| 35 | +resource "gitlab_project" "spack_packages" { |
| 36 | + name = "spack-packages" |
| 37 | + path = "spack-packages" |
| 38 | + namespace_id = gitlab_group.spack.id |
| 39 | + |
| 40 | + visibility_level = "public" |
| 41 | + default_branch = "develop" |
| 42 | + ci_config_path = ".ci/gitlab/.gitlab-ci.yml" |
| 43 | + |
| 44 | + # Keep the protected branches (develop, releases/v*) in sync with GitHub. |
| 45 | + # Production does this with the gh-gl-sync CronJob instead. Staging has no |
| 46 | + # such job. |
| 47 | + # |
| 48 | + # Restricted to protected branches so that pulls never touch testing-branch, |
| 49 | + # and with build triggers off so that a sync of thousands of upstream commits |
| 50 | + # doesn't kick off a protected-branch pipeline. |
| 51 | + import_url = "https://github.com/spack/spack-packages.git" |
| 52 | + mirror = true |
| 53 | + only_mirror_protected_branches = true |
| 54 | + mirror_trigger_builds = false |
| 55 | +} |
| 56 | + |
| 57 | +import { |
| 58 | + to = gitlab_project.spack_packages |
| 59 | + id = "spack/spack-packages" |
| 60 | +} |
| 61 | + |
| 62 | +# Point the buildcache mirrors at the staging buckets. The checked-in |
| 63 | +# .gitlab-ci.yml names the production buckets, and project variables take |
| 64 | +# precedence over its global `variables:` block. |
| 65 | +# |
| 66 | +# These are set on the project rather than committed to testing-branch so that |
| 67 | +# they also cover pipelines on develop, which would otherwise push to the |
| 68 | +# production buildcache. |
| 69 | +resource "gitlab_project_variable" "spack_packages_binary_mirrors" { |
| 70 | + for_each = { |
| 71 | + PR_MIRROR_FETCH_DOMAIN = "s3://spack-binaries-prs-staging" |
| 72 | + PR_MIRROR_PUSH_DOMAIN = "s3://spack-binaries-prs-staging" |
| 73 | + PROTECTED_MIRROR_FETCH_DOMAIN = "s3://spack-binaries-staging" |
| 74 | + PROTECTED_MIRROR_PUSH_DOMAIN = "s3://spack-binaries-staging" |
| 75 | + } |
| 76 | + |
| 77 | + project = gitlab_project.spack_packages.id |
| 78 | + key = each.key |
| 79 | + value = each.value |
| 80 | + |
| 81 | + # testing-branch is not a protected branch, so these have to be available to |
| 82 | + # unprotected refs. |
| 83 | + protected = false |
| 84 | +} |
| 85 | + |
| 86 | +# Restrict pipelines to the build_systems stack and turn off pruning. |
| 87 | +# Like the mirrors above, these override the values in the checked-in .gitlab-ci.yml. |
| 88 | +resource "gitlab_project_variable" "spack_packages_pipeline_scope" { |
| 89 | + for_each = { |
| 90 | + SPACK_CI_ENABLE_STACKS = "/^.*(build_systems).*$/" |
| 91 | + SPACK_PRUNE_UNTOUCHED = "False" |
| 92 | + SPACK_PRUNE_UP_TO_DATE = "False" |
| 93 | + } |
| 94 | + |
| 95 | + project = gitlab_project.spack_packages.id |
| 96 | + key = each.key |
| 97 | + value = each.value |
| 98 | + |
| 99 | + protected = false |
| 100 | + |
| 101 | + # The project-variable equivalent of the `expand: false` that |
| 102 | + # SPACK_CI_ENABLE_STACKS carries in .gitlab-ci.yml, needed because its value |
| 103 | + # contains a `$`. Harmless for the other two, whose values have none. |
| 104 | + raw = true |
| 105 | +} |
| 106 | + |
| 107 | +################################################################################ |
| 108 | +# testing-branch |
| 109 | +# |
| 110 | +# A stable branch of spack-packages to run staging pipelines against. Its |
| 111 | +# contents are an unmodified copy of the default branch; everything that makes a |
| 112 | +# staging pipeline differ from a production one comes from the project variables |
| 113 | +# above. |
| 114 | +# |
| 115 | +# The branch is cut from whatever the default branch currently points at rather |
| 116 | +# than from a pinned commit, so once the mirror above advances develop, the next |
| 117 | +# apply recreates the branch on top of it. Anything pushed to testing-branch by |
| 118 | +# hand is lost when that happens. |
| 119 | +################################################################################ |
| 120 | + |
| 121 | +data "gitlab_branch" "spack_packages_develop" { |
| 122 | + project = gitlab_project.spack_packages.id |
| 123 | + name = gitlab_project.spack_packages.default_branch |
| 124 | +} |
| 125 | + |
| 126 | +resource "gitlab_branch" "spack_packages_testing" { |
| 127 | + project = gitlab_project.spack_packages.id |
| 128 | + name = "testing-branch" |
| 129 | + |
| 130 | + # Resolving develop to a commit is what makes the branch follow it: `ref` |
| 131 | + # forces replacement when it changes, whereas the name "develop" would leave |
| 132 | + # the branch wherever it was first cut. |
| 133 | + ref = one(data.gitlab_branch.spack_packages_develop.commit).id |
| 134 | +} |
0 commit comments