|
| 1 | +name: Compile FrogPilot |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + not_vetted: |
| 7 | + description: "This branch is not vetted" |
| 8 | + required: false |
| 9 | + default: "false" |
| 10 | + type: boolean |
| 11 | + publish_frogpilot: |
| 12 | + description: "Push to FrogPilot" |
| 13 | + required: false |
| 14 | + default: "false" |
| 15 | + type: boolean |
| 16 | + publish_staging: |
| 17 | + description: "Push to FrogPilot-Staging" |
| 18 | + required: false |
| 19 | + default: "false" |
| 20 | + type: boolean |
| 21 | + publish_testing: |
| 22 | + description: "Push to FrogPilot-Testing" |
| 23 | + required: false |
| 24 | + default: "false" |
| 25 | + type: boolean |
| 26 | + publish_custom_branch: |
| 27 | + description: "Push to custom branch:" |
| 28 | + required: false |
| 29 | + default: "" |
| 30 | + type: string |
| 31 | + update_translations: |
| 32 | + description: "Update missing translations" |
| 33 | + required: false |
| 34 | + default: "false" |
| 35 | + type: boolean |
| 36 | + vet_existing_translations: |
| 37 | + description: "Vet existing translations" |
| 38 | + required: false |
| 39 | + default: "false" |
| 40 | + type: boolean |
| 41 | + |
| 42 | +env: |
| 43 | + BASEDIR: "${{ github.workspace }}" |
| 44 | + BUILD_DIR: /data/openpilot |
| 45 | + OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}" |
| 46 | + |
| 47 | +jobs: |
| 48 | + get_branch: |
| 49 | + runs-on: [self-hosted, c3x] |
| 50 | + outputs: |
| 51 | + branch: ${{ steps.get_branch.outputs.branch }} |
| 52 | + python_version: ${{ steps.get_python_version.outputs.python_version }} |
| 53 | + steps: |
| 54 | + - name: Determine Current Branch on Runner |
| 55 | + id: get_branch |
| 56 | + run: | |
| 57 | + cd $BUILD_DIR |
| 58 | +
|
| 59 | + BRANCH=$(git rev-parse --abbrev-ref HEAD) |
| 60 | + echo "branch=$BRANCH" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | + - name: Get Python Version from Runner |
| 63 | + id: get_python_version |
| 64 | + run: | |
| 65 | + PYTHON_VERSION=$(tr -d '[:space:]' < "$BUILD_DIR/.python-version") |
| 66 | + echo "python_version=$PYTHON_VERSION" >> $GITHUB_OUTPUT |
| 67 | +
|
| 68 | + translate: |
| 69 | + if: inputs.update_translations |
| 70 | + needs: get_branch |
| 71 | + runs-on: ubuntu-latest |
| 72 | + steps: |
| 73 | + - name: Configure Git Identity |
| 74 | + run: | |
| 75 | + git config --global user.name "${{ github.actor }}" |
| 76 | + git config --global user.email "${{ github.actor }}@users.noreply.github.com" |
| 77 | +
|
| 78 | + - name: Checkout Required Files |
| 79 | + uses: actions/checkout@v4 |
| 80 | + with: |
| 81 | + ref: ${{ needs.get_branch.outputs.branch }} |
| 82 | + sparse-checkout: | |
| 83 | + selfdrive/controls/lib/alerts_offroad.json |
| 84 | + selfdrive/frogpilot/ui/ |
| 85 | + selfdrive/ui/ |
| 86 | + selfdrive/ui/update_translations.py |
| 87 | + selfdrive/ui/translations/ |
| 88 | + selfdrive/ui/translations/auto_translate.py |
| 89 | +
|
| 90 | + - name: Set Up Python |
| 91 | + uses: actions/setup-python@v4 |
| 92 | + with: |
| 93 | + python-version: "${{ needs.get_branch.outputs.python_version }}" |
| 94 | + |
| 95 | + - name: Install Dependencies |
| 96 | + run: pip install requests |
| 97 | + |
| 98 | + - name: Install Qt5 Tools |
| 99 | + run: sudo apt update && sudo apt install -y qttools5-dev-tools |
| 100 | + |
| 101 | + - name: Update Translations |
| 102 | + run: | |
| 103 | + python selfdrive/ui/update_translations.py --vanish |
| 104 | +
|
| 105 | + - name: Translate Missing or Outdated Translations |
| 106 | + run: python selfdrive/ui/translations/auto_translate.py --all-files ${INPUT_VET:+--vet-translations} |
| 107 | + |
| 108 | + - name: Commit and Push Translation Updates |
| 109 | + run: | |
| 110 | + if git diff --quiet selfdrive/ui/translations/*.ts; then |
| 111 | + echo "No translation updates detected." |
| 112 | + exit 0 |
| 113 | + fi |
| 114 | +
|
| 115 | + git fetch --unshallow origin ${{ needs.get_branch.outputs.branch }} |
| 116 | + git checkout ${{ needs.get_branch.outputs.branch }} |
| 117 | +
|
| 118 | + git add selfdrive/ui/translations/*.ts |
| 119 | + git commit --amend --no-edit |
| 120 | + git push --force origin ${{ needs.get_branch.outputs.branch }} |
| 121 | +
|
| 122 | + build_and_push: |
| 123 | + needs: |
| 124 | + - get_branch |
| 125 | + - translate |
| 126 | + if: always() |
| 127 | + runs-on: [self-hosted, c3x] |
| 128 | + permissions: |
| 129 | + contents: write |
| 130 | + steps: |
| 131 | + - name: Configure Git Identity |
| 132 | + run: | |
| 133 | + git config --global user.name "${{ github.actor }}" |
| 134 | + git config --global user.email "${{ github.actor }}@users.noreply.github.com" |
| 135 | +
|
| 136 | + - name: Update Repository |
| 137 | + run: | |
| 138 | + cd $BUILD_DIR |
| 139 | +
|
| 140 | + git remote set-url origin https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/FrogAi/FrogPilot.git |
| 141 | +
|
| 142 | + if [ "${{ github.event.inputs.update_translations }}" = "true" ]; then |
| 143 | + git fetch origin ${{ needs.get_branch.outputs.branch }} |
| 144 | + git reset --hard origin/${{ needs.get_branch.outputs.branch }} |
| 145 | + git pull origin ${{ needs.get_branch.outputs.branch }} |
| 146 | + fi |
| 147 | +
|
| 148 | + - name: Take Ownership of Build |
| 149 | + run: | |
| 150 | + sudo chown -R $(whoami):$(whoami) $BUILD_DIR |
| 151 | +
|
| 152 | + - name: Finalize Build |
| 153 | + run: | |
| 154 | + cd $BUILD_DIR |
| 155 | +
|
| 156 | + rm -f .clang-tidy |
| 157 | + rm -f .dockerignore |
| 158 | + rm -f .editorconfig |
| 159 | + rm -f .gitattributes |
| 160 | + rm -f .gitmodules |
| 161 | + rm -f .lfsconfig |
| 162 | + rm -f .overlay_init |
| 163 | + rm -f .pre-commit-config.yaml |
| 164 | + rm -f .sconsign.dblite |
| 165 | + rm -f codecov.yml |
| 166 | + rm -f conftest.py |
| 167 | + rm -f poetry.lock |
| 168 | + rm -f pyproject.toml |
| 169 | + rm -f teleoprtc |
| 170 | + rm -f tinygrad |
| 171 | + rm -f Dockerfile.openpilot |
| 172 | + rm -f Dockerfile.openpilot_base |
| 173 | + rm -f Jenkinsfile |
| 174 | +
|
| 175 | + rm -f panda/board/obj/.placeholder |
| 176 | + rm -f panda/board/obj/bootstub.panda.bin |
| 177 | + rm -f panda/board/obj/bootstub.panda.elf |
| 178 | + rm -f panda/board/obj/bootstub.panda_h7.bin |
| 179 | + rm -f panda/board/obj/bootstub.panda_h7.elf |
| 180 | + rm -f panda/board/obj/panda.bin |
| 181 | + rm -f panda/board/obj/panda.elf |
| 182 | + rm -f panda/board/obj/panda_h7.bin |
| 183 | + rm -f panda/board/obj/panda_h7.elf |
| 184 | + rm -f panda/board/obj/version |
| 185 | +
|
| 186 | + find . -name '*.a' -delete |
| 187 | + find . -name '*.cc' -delete |
| 188 | + find . -name '*.o' -delete |
| 189 | + find . -name '*.onnx' -delete |
| 190 | + find . -name '*.os' -delete |
| 191 | + find . -name '*.pyc' -delete |
| 192 | + find . -name 'moc_*' -delete |
| 193 | + find . -name '__pycache__' -exec rm -rf {} + |
| 194 | +
|
| 195 | + find . -name '*.h' | while read -r header; do |
| 196 | + if [[ "$header" != *"common/version.h" && "$header" != *"system/camerad/sensors/"* ]]; then |
| 197 | + rm -f "$header" |
| 198 | + fi |
| 199 | + done |
| 200 | +
|
| 201 | + rm -rf .devcontainer/ |
| 202 | + rm -rf .vscode/ |
| 203 | + rm -rf body/ |
| 204 | + rm -rf opendbc/generator/ |
| 205 | + rm -rf release/ |
| 206 | + rm -rf scripts/ |
| 207 | + rm -rf site_scons/ |
| 208 | + rm -rf teleoprtc_repo/ |
| 209 | +
|
| 210 | + find .github -mindepth 1 -maxdepth 1 ! -name 'workflows' -exec rm -rf {} + |
| 211 | +
|
| 212 | + find .github/workflows -mindepth 1 ! \( \ |
| 213 | + -type f \( \ |
| 214 | + -name 'compile_frogpilot.yaml' -o \ |
| 215 | + -name 'review_pull_request.yaml' -o \ |
| 216 | + -name 'schedule_update.yaml' -o \ |
| 217 | + -name 'update_pr_branch.yaml' -o \ |
| 218 | + -name 'update_release_branch.yaml' \ |
| 219 | + \) \ |
| 220 | + \) -exec rm -rf {} + |
| 221 | +
|
| 222 | + find panda/board/jungle -type f ! -name '__init__.py' -delete |
| 223 | + find panda/board/jungle -type d -empty -delete |
| 224 | +
|
| 225 | + find third_party/ -name '*x86*' -exec rm -rf {} + |
| 226 | + find third_party/ -name '*Darwin*' -exec rm -rf {} + |
| 227 | +
|
| 228 | + find tools/ -mindepth 1 -maxdepth 1 ! \( -name '__init__.py' -o -name 'bodyteleop' -o -name 'lib' \) -exec rm -rf {} + |
| 229 | +
|
| 230 | + find . -name 'SConstruct' -delete |
| 231 | + find . -name 'SConscript' -delete |
| 232 | +
|
| 233 | + find . -type d \( -iname "debug" -o -iname "test" -o -iname "tests" \) -exec rm -rf {} + |
| 234 | + find . -type d -empty ! -path "./.git*" -delete |
| 235 | + find . -type f -regex '.*matlab.*\.md' -delete |
| 236 | +
|
| 237 | + touch prebuilt |
| 238 | +
|
| 239 | + if [ "${{ github.event.inputs.not_vetted }}" = "true" ]; then |
| 240 | + touch not_vetted |
| 241 | + fi |
| 242 | +
|
| 243 | + - name: Commit Build |
| 244 | + run: | |
| 245 | + cd $BUILD_DIR |
| 246 | +
|
| 247 | + git add -f . |
| 248 | + git commit -m "Compile FrogPilot" |
| 249 | + git push --force origin HEAD |
| 250 | +
|
| 251 | + if [ "${{ github.event.inputs.publish_frogpilot }}" = "true" ]; then |
| 252 | + git push --force origin HEAD:"FrogPilot" |
| 253 | + fi |
| 254 | +
|
| 255 | + if [ "${{ github.event.inputs.publish_staging }}" = "true" ]; then |
| 256 | + git push --force origin HEAD:"FrogPilot-Staging" |
| 257 | + fi |
| 258 | +
|
| 259 | + if [ "${{ github.event.inputs.publish_testing }}" = "true" ]; then |
| 260 | + git push --force origin HEAD:"FrogPilot-Testing" |
| 261 | + fi |
| 262 | +
|
| 263 | + if [ -n "${{ github.event.inputs.publish_custom_branch }}" ]; then |
| 264 | + git push --force origin HEAD:"${{ github.event.inputs.publish_custom_branch }}" |
| 265 | + fi |
0 commit comments