Skip to content
This repository was archived by the owner on Jun 20, 2025. It is now read-only.

Commit 982eb01

Browse files
musebcfacebook-github-bot
authored andcommitted
Update the existing Build Images workflow to build all FBPCS images and run on pull requests. (#2150)
Summary: Pull Request resolved: #2150 ## 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. Reviewed By: joe1234wu Differential Revision: D43879194 fbshipit-source-id: 4c542cda2966e796f867322399801cca5b50f60e
1 parent a6c0673 commit 982eb01

File tree

7 files changed

+87
-62
lines changed

7 files changed

+87
-62
lines changed

.github/workflows/build_binary_image.yml

Lines changed: 9 additions & 22 deletions
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

Lines changed: 48 additions & 2 deletions
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.132 # Please also update line 29 in .github/workflows/docker-publish.yml
10+
FBPCF_VERSION: 2.1.132 # 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,12 @@ 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+
2133
build_and_publish_data_processing_image:
2234
name: Build and Publish Data Processing Image
2335
needs: output_version
@@ -37,3 +49,37 @@ jobs:
3749
tag: latest
3850
fbpcf_version: ${{needs.output_version.outputs.fbpcf_version}}
3951
push_to_registry: true
52+
53+
build_test_onedocker_image:
54+
name: Build the bundled test version of the onedocker image
55+
needs: [build_and_publish_data_processing_image, build_and_publish_emp_games_image]
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v3
59+
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@v2
62+
63+
- name: Log into registry ${{ env.REGISTRY }}
64+
uses: docker/login-action@v2
65+
with:
66+
registry: ${{ env.REGISTRY }}
67+
username: ${{ github.actor }}
68+
password: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Build Image
71+
uses: docker/build-push-action@v3
72+
with:
73+
context: .
74+
file: docker/onedocker/test/Dockerfile.ubuntu
75+
tags: |
76+
${{ env.RC_REGISTRY_IMAGE_NAME }}:${{ github.sha }}
77+
build-args: |
78+
tag=${{ github.sha }}
79+
os_release=20.04
80+
private_id_tag=${{ env.PID_VERSION }}
81+
repository_url=${{ env.RC_REGISTRY_URL }}
82+
push: true
83+
pull: true
84+
cache-from: type=gha,scope=onedocker-test-${{ github.ref_name }}
85+
cache-to: type=gha,scope=onedocker-test-${{ github.ref_name }},mode=max

.github/workflows/coordinator-publish.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ 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
@@ -14,7 +11,18 @@ on:
1411
tracker_hash:
1512
description: "[Internal usage] Used for tracking workflow job status within Meta infra"
1613
required: false
17-
type: str
14+
type: string
15+
workflow_call:
16+
inputs:
17+
new_tag:
18+
description: "The new tag of the docker image"
19+
required: false
20+
type: string
21+
default: latest-build
22+
tracker_hash:
23+
description: "[Internal usage] Used for tracking workflow job status within Meta infra"
24+
required: false
25+
type: string
1826

1927
env:
2028
DISTRO: ubuntu
@@ -31,32 +39,29 @@ jobs:
3139
packages: write
3240

3341
steps:
34-
- uses: actions/checkout@v2
42+
- uses: actions/checkout@v3
43+
3544
- name: Print Tracker Hash
36-
run: echo ${{ github.event.inputs.tracker_hash }}
45+
run: echo ${{ inputs.tracker_hash }}
3746

3847
- name: Build image
3948
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 }} .
49+
docker build --build-arg FBPCS_BUNDLE_ID=${{ inputs.new_tag }} -f ./fbpcs/Dockerfile -t ${{ env.LOCAL_IMAGE_NAME }}:${{ inputs.new_tag }} .
4150
4251
# Tests will be added here
4352

4453
- name: Log into registry ${{ env.REGISTRY }}
45-
uses: docker/login-action@v1
54+
uses: docker/login-action@v2
4655
with:
4756
registry: ${{ env.REGISTRY }}
4857
username: ${{ github.actor }}
4958
password: ${{ secrets.GITHUB_TOKEN }}
5059

51-
- name: Set output
52-
id: vars
53-
run: echo ::set-output name=ref::${GITHUB_REF##*/}
54-
5560
- name: Tag docker image
5661
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 }}
62+
docker tag ${{ env.LOCAL_IMAGE_NAME }}:${{ inputs.new_tag }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.sha }}
63+
${{ ! contains(github.ref, 'refs/pull') }} && docker tag ${{ env.LOCAL_IMAGE_NAME }}:${{ inputs.new_tag }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ github.ref_name }}
64+
docker tag ${{ env.LOCAL_IMAGE_NAME }}:${{ inputs.new_tag }} ${{ env.REGISTRY_IMAGE_NAME }}:${{ inputs.new_tag }}
6065
6166
- name: Push image to registry
6267
run: |

.github/workflows/docker-publish.yml

Lines changed: 2 additions & 2 deletions
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.132 # Please also update line 8 in .github/workflows/build_fbpcs_images.yml
26-
PID_VERSION: 0.0.8
25+
FBPCF_VERSION: 2.1.132 # 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

.github/workflows/local_e2e_test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ jobs:
2626
outputs:
2727
matrix: ${{ steps.set-matrix.outputs.matrix }}
2828
steps:
29+
- name: Print Tracker Hash
30+
run: echo ${{ inputs.tracker_hash }}
31+
2932
- uses: actions/checkout@v3
30-
33+
3134
- id: set-matrix
3235
run: echo "matrix=$(find fbpcs/tests/github/bolt_configs/*.yml -printf "%f\n" | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
3336

.github/workflows/test.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

docker/onedocker/test/Dockerfile.ubuntu

Lines changed: 4 additions & 2 deletions
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)