Skip to content

Commit 6b32f47

Browse files
musebcfacebook-github-bot
authored andcommitted
Update the existing Build Images workflow to build all FBPCS images and run on pull requests. (#2213)
Summary: Pull Request resolved: #2213 ## Context We have seen some issues slip through recently that have caused our B&R system to be unstable. Right now, the only testing that we do on diffs is to see if the onedocker image builds. This is insufficient to ensure that changes don't break our B&R system. The new flow for the "Build, Test, and Publish the FBPCS Docker Images" workflow will be to build ~~and test~~ every pull request or push to main ~~with the basic, non-GraphAPI end to end tests~~. For pull requests, it will block the landing of the diff until the ~~tests~~ builds pass. For merges to main, it will create a task and assign it to the person who pushed the commit. This will provide 2 benefits: 1. For pull requests, this adds a higher bar of testing at Diff time. This should block potential bugs from slipping through to block our release flow 2. For merges to main, this will make the tasks more accurate. Since it's running on every commit, it will know which commit likely broke the tests. Right now, it only runs for each bundle from conveyor which might include multiple changes and may not assign the task to the right developer. ## Workflow Design The Build, Test, and Publish the FBPCS Docker Images workflow follows these steps: 1. Build the Coordinator Image 2. In parallel, build the EMP Games and Data Processing images 1. When those are done, build the bundled OneDocker image 3. ~~Once all images are built successfully, run E2E tests~~ {F898944897} ## Updates for V15 I've removed the E2E testing because there is a tag conflict with the RC OneDocker image and will require more effort to include E2E testing. For now, this is still usefull as it makes the builds more like the production release process and includes the coordinator image. ## This Diff This diff updates the already existing workflow that would build images on pushes to main to also build on pull requests and to test the images with the local (non-GraphAPI) E2E tests. Differential Revision: D44229635 fbshipit-source-id: 3742ec2a4abb4f969aaa277f09d1615578269096
1 parent 117198d commit 6b32f47

File tree

5 files changed

+98
-45
lines changed

5 files changed

+98
-45
lines changed

.github/workflows/build_binary_image.yml

+9-22
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ on:
3131
env:
3232
DISTRO: ubuntu
3333
REGISTRY: ghcr.io
34-
RC_REGISTRY_IMAGE_URL: ghcr.io/${{ github.repository }}/rc/
34+
RC_REGISTRY_URL: ghcr.io/${{ github.repository }}/rc/
3535

3636
jobs:
3737
build_image:
@@ -44,17 +44,14 @@ jobs:
4444
steps:
4545
- uses: actions/checkout@v3
4646

47+
- name: Get Docker Image Name
48+
id: get_docker_image_name
49+
run: |
50+
echo "image_tag_name=$(echo ${{ inputs.image_to_build }} | tr '_' '-')" >> $GITHUB_OUTPUT
51+
4752
- name: Set up Docker Buildx
4853
uses: docker/setup-buildx-action@v2
4954

50-
- name: Cache Docker layers
51-
uses: actions/cache@v3
52-
with:
53-
path: /tmp/.buildx-cache
54-
key: ${{ runner.os }}-${{ inputs.image_to_build }}-${{ github.ref_name }}
55-
restore-keys: |
56-
${{ runner.os }}-${{ inputs.image_to_build }}
57-
5855
- name: Pull FBPCF Image
5956
run: docker pull ghcr.io/facebookresearch/fbpcf/ubuntu:${{ inputs.fbpcf_version }}
6057

@@ -71,22 +68,12 @@ jobs:
7168
context: .
7269
file: docker/${{ inputs.image_to_build }}/Dockerfile.ubuntu
7370
tags: |
74-
${{ env.RC_REGISTRY_IMAGE_URL }}${{ inputs.image_to_build }}:${{ github.sha }}
71+
${{ env.RC_REGISTRY_URL }}${{ steps.get_docker_image_name.outputs.image_tag_name }}:${{ github.sha }}
7572
build-args: |
7673
tag=latest
7774
os_release=20.04
7875
fbpcf_image=ghcr.io/facebookresearch/fbpcf/ubuntu:${{ inputs.fbpcf_version }}
7976
push: ${{ inputs.push_to_registry }}
8077
load: ${{ inputs.load_image_locally }}
81-
cache-from: type=local,src=/tmp/.buildx-cache
82-
cache-to: type=local,dest=/tmp/.buildx-cache-new
83-
84-
# This ugly bit is necessary or else our cache will grow forever
85-
# until it hits GitHub's limit of 5GB.
86-
# Temp fix: T135482742
87-
# https://github.com/docker/build-push-action/issues/252
88-
# https://github.com/moby/buildkit/issues/1896
89-
- name: Move cache
90-
run: |
91-
rm -rf /tmp/.buildx-cache
92-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
78+
cache-from: type=gha,scope=${{ steps.get_docker_image_name.outputs.image_tag_name }}-${{ github.ref_name }}
79+
cache-to: type=gha,scope=${{ steps.get_docker_image_name.outputs.image_tag_name }}-${{ github.ref_name }},mode=max

.github/workflows/build_fbpcs_images.yml

+52-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
name: Build and Publish Data Processing and EMP Games Docker Images
1+
name: Build, Test, and Publish the FBPCS Docker Images
22

33
on:
44
push:
55
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
68

79
env:
8-
FBPCF_VERSION: 2.1.144 # Please also update line 25 (FBPCF_VERSION) in .github/workflows/docker-publish.yml
10+
FBPCF_VERSION: 2.1.144 # Please also update line 25 in .github/workflows/docker-publish.yml
11+
PID_VERSION: 0.0.8 # Please also update line 26 in .github/workflows/docker-publish.yml
912
REGISTRY: ghcr.io
13+
LOCAL_IMAGE_NAME: fbpcs/onedocker/test
14+
RC_REGISTRY_URL: ghcr.io/${{ github.repository }}/rc
15+
RC_REGISTRY_IMAGE_NAME: ghcr.io/${{ github.repository }}/rc/onedocker
1016

1117
jobs:
1218
output_version:
@@ -18,6 +24,13 @@ jobs:
1824
- id: set_version
1925
run: echo "version=${{ env.FBPCF_VERSION }}" >> $GITHUB_OUTPUT
2026

27+
build_coordinator_image:
28+
name: Build the Coordinator image
29+
uses: ./.github/workflows/coordinator-publish.yml
30+
with:
31+
new_tag: ${{ github.sha }}
32+
push_to_registry: ${{ github.event_name != pull_request || github.event.pull_request.head.repo.full_name == github.repository }}
33+
2134
build_and_publish_data_processing_image:
2235
name: Build and Publish Data Processing Image
2336
needs: output_version
@@ -26,7 +39,7 @@ jobs:
2639
image_to_build: data_processing
2740
tag: latest
2841
fbpcf_version: ${{needs.output_version.outputs.fbpcf_version}}
29-
push_to_registry: true
42+
push_to_registry: ${{ github.event_name != pull_request || github.event.pull_request.head.repo.full_name == github.repository }}
3043

3144
build_and_publish_emp_games_image:
3245
name: Build and Publish EMP Games Image
@@ -36,4 +49,39 @@ jobs:
3649
image_to_build: emp_games
3750
tag: latest
3851
fbpcf_version: ${{needs.output_version.outputs.fbpcf_version}}
39-
push_to_registry: true
52+
push_to_registry: ${{ github.event_name != pull_request || github.event.pull_request.head.repo.full_name == github.repository }}
53+
54+
build_test_onedocker_image:
55+
name: Build the bundled test version of the onedocker image
56+
needs: [build_and_publish_data_processing_image, build_and_publish_emp_games_image]
57+
runs-on: ubuntu-latest
58+
if: github.event_name != pull_request || github.event.pull_request.head.repo.full_name == github.repository
59+
steps:
60+
- uses: actions/checkout@v3
61+
62+
- name: Set up Docker Buildx
63+
uses: docker/setup-buildx-action@v2
64+
65+
- name: Log into registry ${{ env.REGISTRY }}
66+
uses: docker/login-action@v2
67+
with:
68+
registry: ${{ env.REGISTRY }}
69+
username: ${{ github.actor }}
70+
password: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Build Image
73+
uses: docker/build-push-action@v3
74+
with:
75+
context: .
76+
file: docker/onedocker/test/Dockerfile.ubuntu
77+
tags: |
78+
${{ env.RC_REGISTRY_IMAGE_NAME }}:${{ github.sha }}
79+
build-args: |
80+
tag=${{ github.sha }}
81+
os_release=20.04
82+
private_id_tag=${{ env.PID_VERSION }}
83+
repository_url=${{ env.RC_REGISTRY_URL }}
84+
push: true
85+
pull: true
86+
cache-from: type=gha,scope=onedocker-test-${{ github.ref_name }}
87+
cache-to: type=gha,scope=onedocker-test-${{ github.ref_name }},mode=max

.github/workflows/coordinator-publish.yml

+31-15
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,36 @@ name: Publish Coordinator Image
33
on:
44
workflow_dispatch:
55
inputs:
6-
name:
7-
description: "Manually running this workflow to build a coordinator image"
8-
default: "Run"
96
new_tag:
107
description: "The new tag of the docker image"
118
required: false
129
type: string
1310
default: latest-build
11+
push_to_registry:
12+
description: "Whether or not to push the image to the GitHub Container registry"
13+
required: false
14+
type: boolean
15+
default: true
1416
tracker_hash:
1517
description: "[Internal usage] Used for tracking workflow job status within Meta infra"
1618
required: false
17-
type: str
19+
type: string
20+
workflow_call:
21+
inputs:
22+
new_tag:
23+
description: "The new tag of the docker image"
24+
required: false
25+
type: string
26+
default: latest-build
27+
push_to_registry:
28+
description: "Whether or not to push the image to the GitHub Container registry"
29+
required: false
30+
type: boolean
31+
default: true
32+
tracker_hash:
33+
description: "[Internal usage] Used for tracking workflow job status within Meta infra"
34+
required: false
35+
type: string
1836

1937
env:
2038
DISTRO: ubuntu
@@ -31,33 +49,31 @@ jobs:
3149
packages: write
3250

3351
steps:
34-
- uses: actions/checkout@v2
52+
- uses: actions/checkout@v3
53+
3554
- name: Print Tracker Hash
36-
run: echo ${{ github.event.inputs.tracker_hash }}
55+
run: echo ${{ inputs.tracker_hash }}
3756

3857
- name: Build image
3958
run: |
40-
docker build --build-arg FBPCS_BUNDLE_ID=${{ github.event.inputs.new_tag }} -f ./fbpcs/Dockerfile -t ${{ env.LOCAL_IMAGE_NAME }}:${{ github.event.inputs.new_tag }} .
59+
docker build --build-arg FBPCS_BUNDLE_ID=${{ inputs.new_tag }} -f ./fbpcs/Dockerfile -t ${{ env.LOCAL_IMAGE_NAME }}:${{ inputs.new_tag }} .
4160
4261
# Tests will be added here
4362

4463
- name: Log into registry ${{ env.REGISTRY }}
45-
uses: docker/login-action@v1
64+
uses: docker/login-action@v2
4665
with:
4766
registry: ${{ env.REGISTRY }}
4867
username: ${{ github.actor }}
4968
password: ${{ secrets.GITHUB_TOKEN }}
5069

51-
- name: Set output
52-
id: vars
53-
run: echo ::set-output name=ref::${GITHUB_REF##*/}
54-
5570
- name: Tag docker image
5671
run: |
57-
docker tag ${{ env.LOCAL_IMAGE_NAME }}:${{ github.event.inputs.new_tag }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.sha }}
58-
docker tag ${{ env.LOCAL_IMAGE_NAME }}:${{ github.event.inputs.new_tag }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ steps.vars.outputs.ref }}
59-
docker tag ${{ env.LOCAL_IMAGE_NAME }}:${{ github.event.inputs.new_tag }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.event.inputs.new_tag }}
72+
docker tag ${{ env.LOCAL_IMAGE_NAME }}:${{ inputs.new_tag }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.sha }}
73+
${{ ! contains(github.ref, 'refs/pull') }} && docker tag ${{ env.LOCAL_IMAGE_NAME }}:${{ inputs.new_tag }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.ref_name }}
74+
docker tag ${{ env.LOCAL_IMAGE_NAME }}:${{ inputs.new_tag }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ inputs.new_tag }}
6075
6176
- name: Push image to registry
77+
if: inputs.push_to_registry == true
6278
run: |
6379
docker push --all-tags ${{ env.REGISTRY_IMAGE_NAME }}

.github/workflows/docker-publish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ env:
2222
PL_CONTAINER_NAME: e2e_pl_container
2323
PA_CONTAINER_NAME: e2e_pa_container
2424
TIME_RANGE: 24 hours
25-
FBPCF_VERSION: 2.1.144 # Please also update line 8 in .github/workflows/build_fbpcs_images.yml
26-
PID_VERSION: 0.0.9
25+
FBPCF_VERSION: 2.1.144 # Please also update line 10 in .github/workflows/build_fbpcs_images.yml
26+
PID_VERSION: 0.0.8 # Please also update line 11 in .github/workflows/build_fbpcs_images.yml
2727

2828
jobs:
2929
### Build and publish rc/onedocker image

docker/onedocker/test/Dockerfile.ubuntu

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
ARG os_release="20.04"
66
ARG tag="latest"
77
ARG private_id_tag="latest"
8-
FROM fbpcs/data-processing:${tag} as data_processing
9-
FROM fbpcs/emp-games:${tag} as emp_games
8+
# Use the local repository as default
9+
ARG repository_url="fbpcs"
10+
FROM ${repository_url}/data-processing:${tag} as data_processing
11+
FROM ${repository_url}/emp-games:${tag} as emp_games
1012
FROM ghcr.io/facebookresearch/private-id:${private_id_tag} as private_id
1113

1214
FROM ubuntu:${os_release}

0 commit comments

Comments
 (0)