|
1 | | -name: "~Sandbox" |
2 | | - |
| 1 | +name: Sandbox |
| 2 | +run-name: CI-amd64 |
3 | 3 | on: |
4 | | - workflow_dispatch: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - reopened |
| 8 | + - ready_for_review |
| 9 | + - synchronize |
| 10 | + paths-ignore: |
| 11 | + - "**.md" |
| 12 | + |
| 13 | +env: |
| 14 | + DEFAULT_MANIFEST_ARTIFACT_NAME: bumped-manifest |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read # to fetch code |
| 18 | + actions: write # to cancel previous workflows |
| 19 | + packages: write # to upload container |
5 | 20 |
|
6 | 21 | jobs: |
7 | | - sandbox: |
| 22 | + metadata: |
8 | 23 | runs-on: ubuntu-22.04 |
| 24 | + outputs: |
| 25 | + PUBLISH: ${{ steps.if-publish.outputs.PUBLISH }} |
| 26 | + BUMP_MANIFEST: ${{ steps.manifest-branch.outputs.BUMP_MANIFEST }} |
| 27 | + MANIFEST_ARTIFACT_NAME: ${{ steps.manifest-branch.outputs.MANIFEST_ARTIFACT_NAME }} |
| 28 | + MANIFEST_BRANCH: ${{ steps.manifest-branch.outputs.MANIFEST_BRANCH }} |
| 29 | + MERGE_BUMPED_MANIFEST: ${{ steps.manifest-branch.outputs.MERGE_BUMBED_MANIFEST }} |
9 | 30 | steps: |
10 | | - - name: Login to GitHub Container Registry |
11 | | - uses: docker/login-action@v3 |
12 | | - with: |
13 | | - registry: ghcr.io |
14 | | - username: ${{ github.repository_owner }} |
15 | | - password: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + - name: Set build date |
| 32 | + id: date |
| 33 | + shell: bash -x -e {0} |
| 34 | + run: | |
| 35 | + BUILD_DATE=$(TZ='US/Los_Angeles' date '+%Y-%m-%d') |
| 36 | + echo "BUILD_DATE=${BUILD_DATE}" >> $GITHUB_OUTPUT |
| 37 | +
|
| 38 | + - name: Determine whether results will be 'published' |
| 39 | + id: if-publish |
| 40 | + shell: bash -x -e {0} |
| 41 | + run: | |
| 42 | + echo "PUBLISH=${{ github.event_name == 'schedule' || inputs.PUBLISH }}" >> $GITHUB_OUTPUT |
| 43 | +
|
| 44 | + - name: Set manifest branch name |
| 45 | + id: manifest-branch |
| 46 | + shell: bash -x -e {0} |
| 47 | + run: | |
| 48 | + BUMP_MANIFEST=${{ 'true' }} |
| 49 | + MERGE_BUMPED_MANIFEST=${{ github.event_name == 'schedule' || inputs.MERGE_BUMPED_MANIFEST || 'false' }} |
| 50 | + # Prepend nightly manifest branch with "z" to make it appear at the end |
| 51 | + if [[ "$BUMP_MANIFEST" == "true" ]]; then |
| 52 | + # This branch is for scheduled nightlies or manually run nightlies |
| 53 | + MANIFEST_BRANCH=znightly-${{ steps.date.outputs.BUILD_DATE }}-${{ github.run_id }} |
| 54 | + MANIFEST_ARTIFACT_NAME=${{ env.DEFAULT_MANIFEST_ARTIFACT_NAME }} |
| 55 | + else |
| 56 | + # This branch is for presubmits (no bumping needed) |
| 57 | + MANIFEST_BRANCH=${{ github.sha }} |
| 58 | + # Empty artifact name means to use the one in version control |
| 59 | + MANIFEST_ARTIFACT_NAME="" |
| 60 | + fi |
| 61 | + echo "MANIFEST_BRANCH=$MANIFEST_BRANCH" | tee -a $GITHUB_OUTPUT |
| 62 | + echo "MANIFEST_ARTIFACT_NAME=$MANIFEST_ARTIFACT_NAME" | tee -a $GITHUB_OUTPUT |
| 63 | + echo "BUMP_MANIFEST=$BUMP_MANIFEST" | tee -a $GITHUB_OUTPUT |
| 64 | + echo "MERGE_BUMBED_MANIFEST=$MERGE_BUMPED_MANIFEST" | tee -a $GITHUB_OUTPUT |
| 65 | + if [[ "$BUMP_MANIFEST" == "false" && "$MERGE_BUMPED_MANIFEST" == "true" ]]; then |
| 66 | + echo "Error: If BUMP_MANIFEST=false, MERGE_BUMPED_MANIFEST cannot be true" >&2 |
| 67 | + exit 1 |
| 68 | + fi |
| 69 | +
|
| 70 | + bump-manifest: |
| 71 | + needs: metadata |
| 72 | + runs-on: ubuntu-22.04 |
| 73 | + steps: |
| 74 | + - name: Check out the repository under ${GITHUB_WORKSPACE} |
| 75 | + uses: actions/checkout@v4 |
16 | 76 |
|
17 | | - - name: Print usage |
| 77 | + - name: Test if manifest bump is functional, and save result to a new file |
| 78 | + working-directory: .github/container |
| 79 | + shell: bash -x -e {0} |
18 | 80 | run: | |
19 | | - cat << EOF |
20 | | - This is an empty workflow file located in the main branch of your |
21 | | - repository. It serves as a testing ground for new GitHub Actions on |
22 | | - development branches before merging them to the main branch. By |
23 | | - defining and overloading this workflow on your development branch, |
24 | | - you can test new actions without affecting your main branch, ensuring |
25 | | - a smooth integration process once the changes are ready to be merged. |
26 | | -
|
27 | | - Usage: |
28 | | - |
29 | | - 1. In your development branch, modify the sandbox.yml workflow file |
30 | | - to include the new actions you want to test. Make sure to commit |
31 | | - the changes to the development branch. |
32 | | - 2. Navigate to the 'Actions' tab in your repository, select the |
33 | | - '~Sandbox' workflow, and choose your development branch from the |
34 | | - branch dropdown menu. Click on 'Run workflow' to trigger the |
35 | | - workflow on your development branch. |
36 | | - 3. Once you have tested and verified the new actions in the Sandbox |
37 | | - workflow, you can incorporate them into your main workflow(s) and |
38 | | - merge the development branch into the main branch. Remember to |
39 | | - revert the changes to the sandbox.yml file in the main branch to |
40 | | - keep it empty for future testing. |
41 | | - EOF |
| 81 | + bash bump.sh --input-manifest manifest.yaml --output-manifest manifest.yaml.new --base-patch-dir ./patches-new |
| 82 | +
|
| 83 | + - name: Maybe replace current manifest/patches with the new one and show diff |
| 84 | + working-directory: .github/container |
| 85 | + shell: bash -x -e {0} |
| 86 | + run: | |
| 87 | + if [[ "${{ needs.metadata.outputs.BUMP_MANIFEST }}" == "true" ]]; then |
| 88 | + mv manifest.yaml.new manifest.yaml |
| 89 | + rm -rf patches |
| 90 | + mv patches-new patches |
| 91 | + else |
| 92 | + rm -rf patches-new manifest.yaml.new |
| 93 | + fi |
| 94 | + sed -i 's|file://patches-new/|file://patches/|g' manifest.yaml |
| 95 | + git diff |
| 96 | +
|
| 97 | + - name: Upload bumped manifest/patches to be used in build-base |
| 98 | + if: needs.metadata.outputs.MANIFEST_ARTIFACT_NAME != '' |
| 99 | + uses: actions/upload-artifact@v4 |
| 100 | + with: |
| 101 | + name: ${{ needs.metadata.outputs.MANIFEST_ARTIFACT_NAME }} |
| 102 | + path: | |
| 103 | + .github/container/manifest.yaml |
| 104 | + .github/container/patches |
| 105 | +
|
| 106 | + build-base: |
| 107 | + uses: ./.github/workflows/_build_base.yaml |
| 108 | + needs: [metadata, bump-manifest] |
| 109 | + with: |
| 110 | + ARCHITECTURE: amd64 |
| 111 | + BUILD_DATE: 20240418 |
| 112 | + MANIFEST_ARTIFACT_NAME: ${{ needs.metadata.outputs.MANIFEST_ARTIFACT_NAME }} |
| 113 | + secrets: inherit |
| 114 | + |
| 115 | + build-jax: |
| 116 | + needs: build-base |
| 117 | + uses: ./.github/workflows/_build.yaml |
| 118 | + with: |
| 119 | + ARCHITECTURE: amd64 |
| 120 | + ARTIFACT_NAME: artifact-jax-build |
| 121 | + BADGE_FILENAME: badge-jax-build |
| 122 | + BUILD_DATE: 20240418 |
| 123 | + BASE_IMAGE: ${{ needs.build-base.outputs.DOCKER_TAG }} |
| 124 | + CONTAINER_NAME: jax |
| 125 | + DOCKERFILE: .github/container/Dockerfile.jax |
| 126 | + RUNNER_SIZE: large |
| 127 | + secrets: inherit |
| 128 | + |
| 129 | + build-upstream-maxtext: |
| 130 | + needs: build-jax |
| 131 | + uses: ./.github/workflows/_build.yaml |
| 132 | + with: |
| 133 | + ARCHITECTURE: amd64 |
| 134 | + ARTIFACT_NAME: artifact-maxtext-build |
| 135 | + BADGE_FILENAME: badge-maxtext-build |
| 136 | + BUILD_DATE: 20240418 |
| 137 | + BASE_IMAGE: ${{ needs.build-jax.outputs.DOCKER_TAG_MEALKIT }} |
| 138 | + CONTAINER_NAME: maxtext |
| 139 | + DOCKERFILE: .github/container/Dockerfile.maxtext.amd64 |
| 140 | + secrets: inherit |
| 141 | + |
| 142 | + build-rosetta-maxtext: |
| 143 | + needs: build-upstream-maxtext |
| 144 | + uses: ./.github/workflows/_build_rosetta.yaml |
| 145 | + with: |
| 146 | + ARCHITECTURE: amd64 |
| 147 | + BUILD_DATE: 20240418 |
| 148 | + BASE_IMAGE: ${{ needs.build-upstream-maxtext.outputs.DOCKER_TAG_MEALKIT }} |
| 149 | + BASE_LIBRARY: maxtext |
| 150 | + secrets: inherit |
0 commit comments