|
| 1 | +// Copyright 2022 Flant JSC |
| 2 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +// you may not use this file except in compliance with the License. |
| 4 | +// You may obtain a copy of the License at |
| 5 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +// Unless required by applicable law or agreed to in writing, software |
| 7 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 8 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 9 | +// See the License for the specific language governing permissions and |
| 10 | +// limitations under the License. |
| 11 | + |
| 12 | +//@ts-check |
| 13 | + |
| 14 | +const skipE2eLabel = 'skip/e2e'; |
| 15 | +const abortFailedE2eCommand = '/e2e/abort'; |
| 16 | +module.exports.skipE2eLabel = skipE2eLabel; |
| 17 | +module.exports.abortFailedE2eCommand = abortFailedE2eCommand; |
| 18 | + |
| 19 | +// Labels available for pull requests. |
| 20 | +const labels = { |
| 21 | + // E2E |
| 22 | + 'e2e/run': { type: 'e2e-run', provider: 'static' }, |
| 23 | + // Allow running workflows for external PRs. |
| 24 | + 'status/ok-to-test': { type: 'ok-to-test' }, |
| 25 | + |
| 26 | +}; |
| 27 | +module.exports.knownLabels = labels; |
| 28 | +const userClusterLables = { |
| 29 | + 'e2e/user/nevermarine' : { type: 'e2e-user', id: '72984806'}, |
| 30 | + 'e2e/user/Isteb4k' : { type: 'e2e-user', id: '93128416'} |
| 31 | +}; |
| 32 | +module.exports.userClusterLabels = userClusterLables; |
| 33 | + |
| 34 | +// Label to detect if issue is a release issue. |
| 35 | +const releaseIssueLabel = 'issue/release'; |
| 36 | +module.exports.releaseIssueLabel = releaseIssueLabel; |
| 37 | + |
| 38 | +const slashCommands = { |
| 39 | + deploy: ['deploy/alpha', 'deploy/beta', 'deploy/early-access', 'deploy/stable', 'deploy/rock-solid'], |
| 40 | + suspend: ['suspend/alpha', 'suspend/beta', 'suspend/early-access', 'suspend/stable', 'suspend/rock-solid'] |
| 41 | +}; |
| 42 | +module.exports.knownSlashCommands = slashCommands; |
| 43 | + |
| 44 | +module.exports.labelsSrv = { |
| 45 | + /** |
| 46 | + * Search for known label name using its type and property: |
| 47 | + * - search by provider property for e2e-run labels |
| 48 | + * - search by env property for deploy-web labels |
| 49 | + * |
| 50 | + * @param {object} inputs |
| 51 | + * @param {string} inputs.labelType |
| 52 | + * @param {string} inputs.labelSubject |
| 53 | + * @returns {string} |
| 54 | + */ |
| 55 | + findLabel: ({ labelType, labelSubject }) => { |
| 56 | + return (Object.entries(labels).find(([name, info]) => { |
| 57 | + if (info.type === labelType) { |
| 58 | + if (labelType === 'e2e-run') { |
| 59 | + return info.provider === labelSubject; |
| 60 | + } |
| 61 | + if (labelType === 'deploy-web') { |
| 62 | + return info.env === labelSubject; |
| 63 | + } |
| 64 | + |
| 65 | + return true; |
| 66 | + } |
| 67 | + return false; |
| 68 | + }) || [''])[0]; |
| 69 | + } |
| 70 | +}; |
| 71 | + |
| 72 | +// Providers for e2e tests. |
| 73 | +const providers = Object.entries(labels) |
| 74 | + .filter(([name, info]) => info.type === 'e2e-run') |
| 75 | + .map(([name, info]) => info.provider) |
| 76 | + .sort(); |
| 77 | +module.exports.knownProviders = providers; |
| 78 | + |
| 79 | +// Channels available for deploy. |
| 80 | +const channels = [ |
| 81 | + // |
| 82 | + 'alpha', |
| 83 | + 'beta', |
| 84 | + 'early-access', |
| 85 | + 'stable', |
| 86 | + 'rock-solid' |
| 87 | +]; |
| 88 | + |
| 89 | +module.exports.knownChannels = channels; |
| 90 | + |
| 91 | +const criNames = Object.entries(labels) |
| 92 | + .filter(([name, info]) => info.type === 'e2e-use' && !!info.cri) |
| 93 | + .map(([name, info]) => info.cri); |
| 94 | +module.exports.knownCRINames = criNames; |
| 95 | + |
| 96 | +const kubernetesVersions = Object.entries(labels) |
| 97 | + .filter(([name, info]) => info.type === 'e2e-use' && !!info.ver) |
| 98 | + .map(([name, info]) => info.ver) |
| 99 | + .sort(); |
| 100 | +module.exports.knownKubernetesVersions = kubernetesVersions; |
| 101 | + |
| 102 | +module.exports.e2eDefaults = { |
| 103 | + criName: 'Containerd', |
| 104 | + edition: 'FE', |
| 105 | + multimaster: false, |
| 106 | + cis: false |
| 107 | +}; |
| 108 | + |
| 109 | +const editions = ['CE', 'EE', 'FE', 'BE', 'SE', 'SE-plus']; |
| 110 | +module.exports.knownEditions = editions; |
0 commit comments