Skip to content

Commit

Permalink
fixed build and push full release in CI (#305)
Browse files Browse the repository at this point in the history
* fixed ci workflows

* don't push ota-staging.json and system-skip-chunks-*.img.xz

* add back permissions

* updated raw links

* fixed missing if

* switch to gitlab

* VERSION
  • Loading branch information
andiradulescu authored Aug 12, 2024
1 parent f125aee commit 7f7a7a7
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 52 deletions.
26 changes: 9 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ jobs:
name: build kernel and system
runs-on: namespace-profile-arm64-8x16-2004-caching
timeout-minutes: 60
permissions:
contents: read
pull-requests: write
actions: read
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -41,14 +37,6 @@ jobs:
echo EOF
} | tee -a $GITHUB_ENV
- name: Checkout ci-artifacts
uses: actions/checkout@v4
with:
repository: commaai/ci-artifacts
ssh-key: ${{ secrets.CI_ARTIFACTS_DEPLOY_KEY }}
path: ${{ github.workspace }}/ci-artifacts
ref: master

- name: Get kernel submodule ref
id: kernel-submodule
run: echo "ref=$(git ls-tree HEAD | awk '$4 == "agnos-kernel-sdm845"' | awk '{print $3}')" | tee -a $GITHUB_OUTPUT
Expand All @@ -68,16 +56,20 @@ jobs:
- name: Package and OTA push
if: "contains(env.LAST_COMMIT_MESSAGE, '[upload]')"
env:
AGNOS_UPDATE_URL: https://raw.githubusercontent.com/commaai/ci-artifacts/agnos-builder/pr-${{ github.event.number }}/
AGNOS_UPDATE_URL: https://gitlab.com/commaai/ci-artifacts/-/raw/agnos-builder/pr-${{ github.event.number }}/
run: |
scripts/package_ota.py
- name: Save PR number and VERSION
if: "contains(env.LAST_COMMIT_MESSAGE, '[upload]')"
run: |
echo ${{ github.event.number }} > output/ota/PR
cp VERSION output/ota
- name: Upload artifacts
if: "contains(env.LAST_COMMIT_MESSAGE, '[upload]')"
uses: actions/upload-artifact@v4
with:
name: agnos-artifacts-${{ github.event.number }}
path: |
${{ github.workspace }}/output/ota/*.img.xz
${{ github.workspace }}/output/ota/ota.json
name: agnos-artifacts
path: output/ota
compression-level: 0
85 changes: 52 additions & 33 deletions .github/workflows/push-and-comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,82 @@ on:
types:
- completed

env:
BUILD_JOB_NAME: "build kernel and system"

jobs:
preview:
name: push and comment
push-and-comment:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
timeout-minutes: 15
timeout-minutes: 5
permissions:
contents: read
pull-requests: write
actions: read
steps:
- name: Get workflow run ID
id: get_run_id
run: |
echo "run_id=$(curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }}/check-runs | jq -r '.check_runs[] | select(.name == "${{ env.BUILD_JOB_NAME }}") | .html_url | capture("(?<number>[0-9]+)") | .number')" >> $GITHUB_OUTPUT
- name: Setup SSH key
uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387
with:
ssh-private-key: ${{ secrets.CI_ARTIFACTS_GITLAB_DEPLOY_KEY }}

- name: Checkout ci-artifacts
uses: actions/checkout@v4
with:
repository: commaai/ci-artifacts
ssh-key: ${{ secrets.CI_ARTIFACTS_DEPLOY_KEY }}
path: ${{ github.workspace }}/ci-artifacts
ref: master
run: |
ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
git clone -b main [email protected]:commaai/ci-artifacts.git ${{ github.workspace }}/ci-artifacts
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v6
uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
run_id: ${{ steps.get_run_id.outputs.run_id }}
search_artifacts: true
name: agnos-artifacts-${{ github.event.number }}
run_id: ${{ github.event.workflow_run.id }}
name: agnos-artifacts
path: ${{ github.workspace }}/ci-artifacts

- name: Read PR number and VERSION
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const prNumber = fs.readFileSync('${{ github.workspace }}/ci-artifacts/PR', 'utf8').trim();
core.exportVariable('PR_NUMBER', prNumber);
const version = fs.readFileSync('${{ github.workspace }}/ci-artifacts/VERSION', 'utf8').trim();
core.exportVariable('VERSION', version);
- name: Push boot, system and agnos.json
working-directory: ${{ github.workspace }}/ci-artifacts
run: |
mv ota.json agnos.json
git checkout -b agnos-builder/pr-${{ github.event.number }}
mv ota.json agnos.json && rm ota-staging.json system-skip-chunks-*.img.xz
git checkout -b agnos-builder/pr-${{ env.PR_NUMBER }}
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git lfs track "*.xz"
git add .
git commit -m "build artifacts for PR #${{ github.event.number }}"
git push origin agnos-builder/pr-${{ github.event.number }} --force
git commit -m "build artifacts for PR #${{ env.PR_NUMBER }}"
git push origin agnos-builder/pr-${{ env.PR_NUMBER }} --force
- name: List .xz files with links
id: list_xz
working-directory: ${{ github.workspace }}/ci-artifacts
run: |
{
echo 'XZ_FILES<<EOF'
for file in *.xz; do
echo "* [$file](https://gitlab.com/commaai/ci-artifacts/-/raw/agnos-builder/pr-${{ env.PR_NUMBER }}/$file)"
done
echo EOF
} >> $GITHUB_ENV
- name: Comment on PR
uses: thollander/actions-comment-pull-request@v2
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6
with:
message: |
<!-- _(run_id **${{ github.run_id }}**)_ -->
## Build agnos.json
Download <a href="https://raw.githubusercontent.com/commaai/ci-artifacts/agnos-builder/pr-${{ github.event.number }}/agnos.json" target="_blank">agnos.json</a> and replace `openpilot/system/hardware/tici/agnos.json` in your openpilot branch.
<!-- _(run_id **${{ github.event.workflow_run.id }}**)_ -->
## :white_check_mark: AGNOS update ${{ env.VERSION }} ready
In an openpilot branch, download <a href="https://gitlab.com/commaai/ci-artifacts/-/raw/agnos-builder/pr-${{ env.PR_NUMBER }}/agnos.json">agnos.json</a> in `system/hardware/tici/` and update `AGNOS_VERSION` to **${{ env.VERSION }}** in `launch_env.sh`.
If you need to flash locally, you can download the <a href="https://github.com/commaai/ci-artifacts/tree/agnos-builder/pr-${{ github.event.number }}" target="_blank">images</a> and unarchive them in `agnos-builder/output` and flash with `./flash_all.sh`.
For flashing locally, download and unarchive the images in `agnos-builder/output` and flash with `./flash_all.sh`.
---
### Images:
${{ env.XZ_FILES }}
pr_number: ${{ env.PR_NUMBER }}
comment_tag: run_id
pr_number: ${{ github.event.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
mode: recreate
4 changes: 2 additions & 2 deletions Dockerfile.agnos
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ RUN /tmptmp/readonly_setup.sh && rm -rf /tmptmp
# copy at the end, after all apt usage
COPY ./userspace/files/apt.conf /etc/apt/apt.conf

# Write version file
RUN echo -n "10.1" > /VERSION
# copy version file
COPY VERSION /VERSION

# ################## #
# #### Cleaunup #### #
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.1

0 comments on commit 7f7a7a7

Please sign in to comment.