Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
247 changes: 1 addition & 246 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,246 +1 @@
version: 2.1

orbs:
gcloud: circleci/gcp-cli@3.0.1

###
# These correspond to variables that are passed to packer.
# Update any of the anchors so changes propagate to downstream builds. For example, source_image will override source_image_family.
# If you were patching, you might want to use a specified source_image rather than the latest ubuntu source image, which
# is what the source_image_family would point to. If building the latest new image, you might want to build from source_image_family
#

# For full intraquarterly builds, the base_image includes common circleci modules and retains the original software from that point
# in time. Using this will also decrease build times
###

configuration:
gcp_global:
- gcp_zone: &gcp_zone "us-east1-c"
- gcp_ssh_username: &gcp_ssh_username "circleci"

gcp_focal:
- gcp_focal_source_image: &gcp_focal_source_image "ubuntu-2004-focal-v20230302"
- gcp_focal_base_image_name: &gcp_focal_base_image_name "ansible-ubuntu-2004-base"
- gcp_focal_source_image_family: &gcp_focal_source_image_family "ubuntu-2004-lts"
# Canary
- gcp_focal_canary_image_name: &gcp_focal_canary_image_name "ansible-ubuntu-2004-canary"

gcp_jammy:
- gcp_jammy_source_image: &gcp_jammy_source_image "ubuntu-2204-jammy-v20230428"
- gcp_jammy_base_image_name: &gcp_jammy_base_image_name "ansible-ubuntu-2204-base"
- gcp_jammy_source_image_family: &gcp_jammy_source_image_family "ubuntu-2204-lts"
# Canary
- gcp_jammy_canary_image_name: &gcp_jammy_canary_image_name "ansible-ubuntu-2204-canary"

gcp_tags:
- gcp_jammy_base_tag: &gcp_jammy_base_tag "2023.06.base"
- gcp_jammy_test_tag: &gcp_jammy_test_tag "2023.06.test"
# Canary
- gcp_jammy_canary_tag: &gcp_jammy_canary_tag "2023.06.1"

parameters:
build_quarterly:
type: boolean
default: false
build_canary:
type: boolean
default: false

workflows:
build-quarterly:
when: << pipeline.parameters.build_quarterly >>
jobs:
- build_gcp:
filters:
branches:
only:
- /build.*/
name: gcp_jammy_quarterly
run_build: true
source_dirs: "manifest/software.json"
zone: *gcp_zone
source_image: *gcp_jammy_source_image
image_name: *gcp_jammy_base_image_name
image_tag: *gcp_jammy_base_tag
image_family: *gcp_jammy_base_image_name
source_image_family: *gcp_jammy_source_image_family
project_id: GOOGLE_PROJECT_ID
ssh_username: *gcp_ssh_username
playbook_file: "./linux-playbook.yml"
context: vm-publishing
build-canary:
when: << pipeline.parameters.build_canary >>
jobs:
- build_gcp:
filters:
branches:
only:
- /canary.*/
name: gcp_jammy_canary
run_build: true
source_dirs: "manifest/software.json"
zone: *gcp_zone
source_image: ""
image_name: *gcp_jammy_canary_image_name
image_tag: *gcp_jammy_canary_tag
image_family: *gcp_jammy_canary_image_name
source_image_family: *gcp_jammy_canary_image_name
project_id: GOOGLE_PROJECT_ID
playbook_file: "./linux-playbook.yml"
context: vm-publishing
build-test:
jobs:
- build_gcp:
filters:
branches:
only:
- /test.*/
- /refactor.*/
- /fix.*/
- /feat.*/
name: gcp_tests
run_build: false
source_dirs: "manifest/software.json"
zone: *gcp_zone
source_image: "ubuntu-2204-jammy-v20230616"
image_name: linux-2204-q3
image_tag: *gcp_jammy_test_tag
image_family: test-runs
source_image_family: *gcp_jammy_source_image_family
project_id: GOOGLE_PROJECT_ID
skip_create_image: true
playbook_file: "./linux-playbook-test.yml"
context: vm-publishing

executors:
deploy:
docker:
- image: cimg/deploy:2023.04

jobs:
build_gcp:
executor: deploy
parameters:
run_build:
type: boolean
default: false
description:
Use this to force a rebuild, even if there are no changes in source_dirs. This is useful if the build is correct, but
you still need to do a re-run. e.g patch
source_dirs:
type: string
zone:
type: string
source_image:
type: string
default: ""
image_name:
type: string
image_tag:
type: string
image_family:
type: string
source_image_family:
type: string
default: ""
ssh_username:
type: string
default: "circleci"
account_file:
type: string
default: "/tmp/account.json"
project_id:
type: env_var_name
extra_vars:
type: string
default: ""
skip_create_image:
type: boolean
default: false
playbook_file:
type: string
environment:
RUN_BUILD: << parameters.run_build >>
steps:
- checkout
- check_source_paths:
source_dirs: << parameters.source_dirs >>
- run:
name: Generate Credentials
command: |
echo "${CCI_GCE_B64_CREDENTIALS}" | base64 -d > /tmp/account.json
shell: bash
- gcloud/install:
components: "beta"
- run: |
gcloud auth login --brief --cred-file /tmp/account.json
- run: sudo apt-get update
- run: mkdir -p /tmp/workspace
- run:
name: Configure Packer Variables
command: |
cat > packer_vars \<<EOF
export PKR_VAR_zone="<< parameters.zone >>"
export PKR_VAR_source_image="<< parameters.source_image >>"
export PKR_VAR_image_name="<< parameters.image_name >>"
export PKR_VAR_image_family="<< parameters.image_family >>"
export PKR_VAR_source_image_family="<< parameters.source_image_family >>"
export PKR_VAR_account_file="<< parameters.account_file >>"
export PKR_VAR_project_id="${<< parameters.project_id >>}"
export PKR_VAR_ssh_username="<< parameters.ssh_username >>"
export PKR_VAR_skip_create_image="<< parameters.skip_create_image >>"
export PKR_VAR_playbook_file="<< parameters.playbook_file >>"
EOF
- run:
name: Build Images
no_output_timeout: 120m
command: |
source packer_vars && sudo cp packer_vars /tmp/workspace
packer build \
-machine-readable \
-only=googlecompute.gcp-canary-base \
packer/
- run:
name: Persist files
command: |
echo ${CIRCLE_BUILD_URL} > /tmp/workspace/build_url
sudo cp << parameters.source_dirs >> /tmp/workspace/manifest
- persist_to_workspace:
root: /tmp/workspace
paths:
- packer_vars
- build_url
- manifest
- store_artifacts:
path: /tmp/workspace

commands:
check_source_paths:
parameters:
source_dirs:
type: string
description: |
Runs a git diff on the specified manifest and runs the build if a change has been detected from in the feature branch
compared to the default branch. Use the `run_build` parameter to override if no changes were made
steps:
- run:
name: "Continue image job only if the correct paths were modified"
command: |
CHANGE="false"

if [[ $CIRCLE_BRANCH != "main" ]]; then
git diff --quiet HEAD main -- "<< parameters.source_dirs >>" || CHANGE="true"
echo "$CHANGE"
fi

if [[ $RUN_BUILD != true ]]; then
if [[ $CHANGE != "false" ]] && [[ $CIRCLE_BRANCH != "main" ]]; then
echo "run_build set to false, but changes in source_dirs detected. Continuing with build.
This is the default behavior. If this is not intentional, please check << parameters.source_dirs >> for changes"
else
circleci step halt
fi
else
echo "run_build set to true. Continuing with build"
fi
# TODO: Setup validation and tests
41 changes: 0 additions & 41 deletions linux-playbook-test.yml

This file was deleted.

79 changes: 0 additions & 79 deletions manifest/android-test.json

This file was deleted.

8 changes: 0 additions & 8 deletions manifest/docker23.json

This file was deleted.

8 changes: 0 additions & 8 deletions manifest/docker24.json

This file was deleted.

Loading