CloudSnorkel / cdk-github-runners

CDK constructs for self-hosted GitHub Actions runners
https://constructs.dev/packages/@cloudsnorkel/cdk-github-runners/
Apache License 2.0
255 stars 37 forks source link

Waiting for a runner to pick up this job... #516

Closed nkhine closed 2 months ago

nkhine commented 2 months ago

Hello, I have setup the stack as part of my project, here is the cdk code:

import {
  GitHubRunners,
  Ec2RunnerProvider,
  CodeBuildRunnerProvider,
  LambdaRunnerProvider,
} from "@cloudsnorkel/cdk-github-runners";
import {
  StackProps,
} from "aws-cdk-lib";
import {
  GatewayVpcEndpointAwsService,
  InstanceClass,
  InstanceSize,
  InstanceType,
  IpAddresses,
  Vpc,
} from "aws-cdk-lib/aws-ec2";
import { NagSuppressions } from "cdk-nag";
import { Construct } from "constructs";
import { Config } from "../../config";
import TaggingStack from "../../tagging";

export interface RunnersStackProps extends StackProps {
  config: Config;
}

export class RunnersStack extends TaggingStack {
  public readonly vpc: Vpc;
  constructor(scope: Construct, id: string, props: RunnersStackProps) {
    super(scope, id, props);
    const config = props.config.stage;
    this.vpc = new Vpc(this, "InfraVPC", {
      ipAddresses: IpAddresses.cidr(config.vpc.cidr),
      enableDnsSupport: true,
      enableDnsHostnames: true,
      maxAzs: config.vpc.maxAzs,
      natGateways: config.vpc.maxAzs,
      natGatewayProvider: NatProvider.instance({
        instanceType: InstanceType.of(InstanceClass.T2, InstanceSize.MICRO),
      }),
      gatewayEndpoints: {
        // Keep S3 <-> Apps traffic and
        // ECR <-> Apps traffic in the VPC to reduce data transfer costs
        S3: { service: GatewayVpcEndpointAwsService.S3 },
      },
    });

    const providers = config.providers.type.map((providerType) => {
      switch (providerType) {
        case "EC2":
          return new Ec2RunnerProvider(this, `${providerType}Provider`, {
            vpc: this.vpc,
          });
        case "CodeBuild":
          return new CodeBuildRunnerProvider(this, `${providerType}Provider`);
        case "Lambda":
          return new LambdaRunnerProvider(this, `${providerType}Provider`);
        default:
          throw new Error(`Unsupported provider type: ${providerType}`);
      }
    });

    new GitHubRunners(this, "GitHubRunners", {
      providers,
      requireSelfHostedLabel: true,
      vpc: this.vpc,
    });
    NagSuppressions.addResourceSuppressions(
      this.vpc,
      [
        {
          id: "AwsPrototyping-VPCSubnetAutoAssignPublicIpDisabled",
          reason: "I'm okay for this to happen",
        },
      ],
      true,
    );
  }
}

Everything gets deployed without any errors.

When I try to run the tests as per self_hosted.yml example:

name: self-hosted example
on: push
jobs:
  self-hosted:
    runs-on: [self-hosted, lambda]
    steps:
      - run: echo hello world

The workflow starts, but it just hangs with the message

Waiting for a runner to pick up this job...

I have checked the logs for the webhook trigger and this has fired, but in the logs I have

2024-03-02T13:57:27.561Z    0cf02704-88db-4e8d-a869-bfd79b012a86    INFO    Ignoring action "completed", expecting "queued"

What am I missing?

kichik commented 2 months ago

Code seems fine. Are you sure the app and/or webhook is registered on the right repo? Check the webhook delivery history on GitHub side to confirm if it sent an event for the job you created.

nkhine commented 2 months ago

@kichik thanks for the reply, my issue was that i was using the wrong runs-on: [self-hosted, lambda] labels