Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slack channels per matrix #394

Closed
apujari-hippo opened this issue Mar 16, 2023 · 6 comments
Closed

Slack channels per matrix #394

apujari-hippo opened this issue Mar 16, 2023 · 6 comments
Labels
backlog Identified as a backlog item, often combined with low-priority and help-wanted labels bug Something isn't working

Comments

@apujari-hippo
Copy link

Orb version: 4.12.1

What happened:

I have a list of jobs (aka tests) that run parallelly. I would like to send the status of each job to a separate slack channel.

I have included a sample in the additional information section. The current sample code only lists only 3 tests, but my actual config in production has 95 tests.

How can I achieve this?

Expected behavior:

I was thinking of some kind of key-value pair matrix where I can pass the test name and channel name which can be referenced in the later part of the config.

Additional Information:

Sample GIST: https://gist.github.com/apujari-hippo/50cb076627d3a27adfc93aeb14690faf

@apujari-hippo apujari-hippo added the bug Something isn't working label Mar 16, 2023
@KyleTryon
Copy link
Contributor

Hey @apujari-hippo,

What you are looking to do is possible but unfortunately outside the realm of what the matrix feature of CircleCI is capable of. The matrix feature automatically makes combinations of each supplied parameter. That's useful when you want to test multiple browsers on multiple versions of node for example, but does not help here were you want to "group" parameters together.

Rather than using the matrix feature, I recommend expanding your config one level up like this:

- deploy:
    name: test-x
    test-name: test-x
    slack-channel:  channel-x
- deploy:
    name: test-y
    test-name: test-y
    slack-channel:  channel-y

Config SDK

It may be overkill for a situation like this, but the ConfigSDK can be used to make matrix-like jobs using Dynamic Config and Javascript.
https://github.com/CircleCI-Public/circleci-config-sdk-ts/wiki

example:

//index.ts
import * as CircleCI from '@circleci/circleci-config-sdk';
import { testJob, deployJob } from './jobs';
import { isDeployable } from './utils';

const myConfig = new CircleCI.Config();
const myWorkflow = new CircleCI.Workflow('my-workflow');

// Support the three latest versions of Node
const nodeVersions = ["16.19", "18.13", "19.7"];

const testJobs = nodeVersions.map((version) => testJob(version));
testJobs.forEach((job) => {
  myConfig.addJob(job);
  myWorkflow.addJob(job)
});

if (isDeployable()) {
  myConfig.addJob(deployJob);
  myWorkflow.addJob(deployJob, {
    requires: testJobs.map((job) => job.name)
  });
}

myConfig.addWorkflow(myWorkflow);
myConfig.writeFile('dynamicConfig.yml')
// jobs/index.ts
import * as CircleCI from "@circleci/circleci-config-sdk";
import { nodeExecutor } from "../executors";

function sanetizeVersion(version: string) {
  return version.replace(".", "-");
}

const testJob = (version: string) =>
  new CircleCI.Job(`test-${sanetizeVersion(version)}`, nodeExecutor(version), [
    new CircleCI.commands.Checkout(),
    new CircleCI.commands.Run({
      command: "npm install && npm run test",
    }),
  ]);

const deployJob = new CircleCI.Job(
  "deploy",
  nodeExecutor("14"),
  [
    new CircleCI.commands.Checkout(),
    new CircleCI.commands.Run({
      command: "npm install && npm run deploy"
    })
  ]
)

export { testJob, deployJob }

@apujari-hippo
Copy link
Author

@KyleTryon The problem with the above solution is the YAML is too big for the Circle CI to ingest, as we have 92 tests in there.

@KyleTryon
Copy link
Contributor

What is the total size of the config? I have seen some interesting configs with even more than 92 jobs in them.

@apujari-hippo
Copy link
Author

-rw-r--r-- 1 apujari staff 13K Apr 12 15:22 .circleci/config.yml
The current size of the file is 13K

@KyleTryon
Copy link
Contributor

@apujari-hippo sorry for the late reply. 13K is well within the limits. It sounds like that might be your config before the 92 jobs. What would it be with? You have several megabytes to work with.

@KyleTryon KyleTryon added the backlog Identified as a backlog item, often combined with low-priority and help-wanted labels label May 25, 2023
@marboledacci
Copy link
Contributor

I'm closing this as there hasn't been a comment in more than a year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Identified as a backlog item, often combined with low-priority and help-wanted labels bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants