Skip to content

Commit

Permalink
Reorganize workflows so that they are all dependent on the same tests…
Browse files Browse the repository at this point in the history
…uite passing

Case RE-1026: Testsuit.yml as parent to OpenStack workflows.

Changelog:
  • Loading branch information
davelcpanelnet authored and Travis Holloway committed Dec 11, 2024
1 parent c69f1e8 commit 62be12e
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 25 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/openstack-centos-7.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: "Test Run: centos-7"

on:
push:
branches:
- "main"
- '!docs'
tags-ignore:
- "*"
pull_request:
workflow_dispatch:
inputs:
message:
description: 'Build description CentOS 7'

workflow_run:
workflows: ["TestSuite"]
types:
- completed

workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-openstack-centos-7
Expand All @@ -17,6 +20,8 @@ concurrency:
env:
TF_VAR_application_credential_id: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
TF_VAR_application_credential_secret: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
TF_VAR_github_repository: ${{ github.repository }}
TF_VAR_github_run_id: ${{ github.run_id }}
TF_VAR_ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
TF_VAR_ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
TF_VAR_os_auth_region: ${{ secrets.OS_AUTH_REGION }}
Expand All @@ -32,10 +37,7 @@ env:
tf_working_directory: "${{ github.workspace }}/.github/workflows/openstack/centos-7"

jobs:
testsuite:
uses: ./.github/workflows/testsuite.yml
terraform_openstack_create:
needs: [testsuite]
runs-on: self-hosted
defaults:
run:
Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/openstack-cloudlinux-7.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: "Test Run: cloudlinux-7"

on:
push:
branches:
- "main"
- '!docs'
tags-ignore:
- "*"
pull_request:
workflow_dispatch:
inputs:
message:
description: 'Build description CloudLinux 7'

workflow_run:
workflows: ["TestSuite"]
types:
- completed

workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-openstack-cloudlinux-7
Expand All @@ -17,6 +20,8 @@ concurrency:
env:
TF_VAR_application_credential_id: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
TF_VAR_application_credential_secret: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
TF_VAR_github_repository: ${{ github.repository }}
TF_VAR_github_run_id: ${{ github.run_id }}
TF_VAR_ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
TF_VAR_ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
TF_VAR_os_auth_region: ${{ secrets.OS_AUTH_REGION }}
Expand All @@ -32,10 +37,7 @@ env:
tf_working_directory: "${{ github.workspace }}/.github/workflows/openstack/cloudlinux-7"

jobs:
testsuite:
uses: ./.github/workflows/testsuite.yml
terraform_openstack_create:
needs: [testsuite]
runs-on: self-hosted
defaults:
run:
Expand All @@ -56,6 +58,7 @@ jobs:
- name: Terraform Plan
id: plan
run: |
env
terraform plan -no-color
- name: Terraform Apply
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/openstack/centos-7/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ resource "openstack_compute_keypair_v2" "tf_remote_key" {
}

resource "openstack_compute_instance_v2" "elevatevm" {
name = "elevate.github.cpanel.net"
name = "${var.github_run_id}.${var.github_repository}.github.cpanel.net"
image_id = data.openstack_images_image_ids_v2.images.ids[0]
flavor_name = var.flavor_name
key_pair = openstack_compute_keypair_v2.tf_remote_key.name
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/openstack/centos-7/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ variable "application_credential_secret" {
type = string
}

variable "github_repository" {
type = string
}

variable "github_run_id" {
type = string
}

variable "os_password" {
type = string
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/openstack/cloudlinux-7/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ resource "openstack_compute_keypair_v2" "tf_remote_key" {
}

resource "openstack_compute_instance_v2" "elevatevm" {
name = "elevate.github.cpanel.net"
name = "${var.github_run_id}.${var.github_repository}.github.cpanel.net"
image_id = data.openstack_images_image_ids_v2.images.ids[0]
flavor_name = var.flavor_name
key_pair = openstack_compute_keypair_v2.tf_remote_key.name
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/openstack/cloudlinux-7/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ variable "application_credential_secret" {
type = string
}

variable "github_repository" {
type = string
}

variable "github_run_id" {
type = string
}

variable "os_password" {
type = string
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/openstack/prune_openstack
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use warnings;
# Static constants
use constant {
KEY_NAME => "deletethis",
VM_NAME => "elevate.github.cpanel.net",
VM_NAME => "$ENV{TF_VAR_github_repository}.github.cpanel.net",
};

my $openstack_path = "/usr/bin/openstack" if -x "/usr/bin/openstack";
Expand Down
31 changes: 29 additions & 2 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: testsuite
name: TestSuite

on:
push:
Expand All @@ -9,12 +9,29 @@ on:
- "*"
pull_request:
workflow_dispatch:
workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-testsuite
cancel-in-progress: true

env:
TF_VAR_application_credential_id: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
TF_VAR_application_credential_secret: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
TF_VAR_github_repository: ${{ github.repository }}
TF_VAR_github_run_id: ${{ github.run_id }}
TF_VAR_ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
TF_VAR_ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
TF_VAR_os_auth_region: ${{ secrets.OS_AUTH_REGION }}
TF_VAR_os_auth_url: ${{ secrets.OS_AUTH_URL }}
TF_VAR_os_interface: ${{ secrets.OS_INTERFACE }}
TF_VAR_os_project_domain_name: ${{ secrets.OS_PROJECT_DOMAIN_NAME }}
TF_VAR_os_password: ${{ secrets.OS_PASSWORD }}
TF_VAR_os_project_id: ${{ secrets.OS_PROJECT_ID }}
TF_VAR_os_project_domain_id: ${{ secrets.OS_PROJECT_DOMAIN_ID }}
TF_VAR_os_project_name: ${{ secrets.OS_PROJECT_NAME }}
TF_VAR_os_region_name: ${{ secrets.OS_REGION_NAME }}
TF_VAR_os_username: ${{ secrets.OS_USERNAME }}

jobs:
testsuite:
env:
Expand Down Expand Up @@ -61,3 +78,13 @@ jobs:
- name: Run tests
run: prove -lv -It/lib t/*.t

CentOS-7:
needs: testsuite
uses: ./.github/workflows/openstack-centos-7.yml
secrets: inherit

CloudLinux-7:
needs: testsuite
uses: ./.github/workflows/openstack-cloudlinux-7.yml
secrets: inherit

0 comments on commit 62be12e

Please sign in to comment.