mirror of
https://github.com/clangd/clangd.git
synced 2024-12-04 21:17:10 +00:00
Merge periodic workflow into autobuild (#786)
The only reason to have a separate periodic action was the ability to run the action "manually" by creating an appropriate release. With the workflow_dispatch, we can actually trigger the workflow manually with a convenient UI. Hence, periodic is no longer needed.
This commit is contained in:
parent
c576bf40d1
commit
c0845399c6
191
.github/workflows/autobuild.yaml
vendored
191
.github/workflows/autobuild.yaml
vendored
@ -1,41 +1,143 @@
|
||||
# Workflow to build binaries for a release.
|
||||
# Triggered by release creation, which should include `llvm-project@<full-sha>`.
|
||||
# Workflow to build binaries and release them.
|
||||
# Triggered by the schedule or manual dispatch, which might include
|
||||
# `<owner/llvm-project>@<full-sha>`.
|
||||
#
|
||||
# Because the build takes more than an hour, our GITHUB_TOKEN credentials may
|
||||
# expire. A token `secrets.RELEASE_TOKEN` must exist with public_repo scope.
|
||||
name: Build release binaries
|
||||
on:
|
||||
release:
|
||||
types: created
|
||||
# Run weekly on sunday at 21:37 UTC (arbitrary)
|
||||
schedule:
|
||||
- cron: '37 21 * * SUN'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
commit:
|
||||
description: 'Commit to build from'
|
||||
required: true
|
||||
repo:
|
||||
description: 'Repository to build from'
|
||||
required: true
|
||||
default: 'llvm/llvm-project'
|
||||
release_name:
|
||||
description: 'Release name'
|
||||
required: true
|
||||
tag:
|
||||
description: 'Tag name'
|
||||
required: true
|
||||
description:
|
||||
description: 'Release description'
|
||||
required: true
|
||||
jobs:
|
||||
prepare:
|
||||
schedule_environment:
|
||||
name: Create default build environment
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name == 'schedule' }}
|
||||
steps:
|
||||
- name: Find LLVM commit
|
||||
- name: Install deps
|
||||
run: |
|
||||
perl -ne 'print "LLVM_REPO=$1\nLLVM_COMMIT=$2\n" if /(\w+\/llvm-project)@([[:xdigit:]]{40,})/' > commit.env <<EOF
|
||||
${{ github.event.release.body }}
|
||||
EOF
|
||||
- name: Check LLVM commit was founud
|
||||
run: grep LLVM_REPO commit.env
|
||||
- name: Mark as draft
|
||||
sudo apt-get install jq
|
||||
- name: Clone scripts
|
||||
uses: actions/checkout@v2
|
||||
# Choose the commit to build a release from.
|
||||
#
|
||||
# We want to avoid unbuildable revisions: choose the last green from CI.
|
||||
# FIXME: The criteria should be some consistent set of buildbots passing.
|
||||
# Use clangd/actions/pick after
|
||||
# https://github.com/ramasilveyra/last-successful-gh-commit/issues/2 has
|
||||
# been addressed.
|
||||
- name: Get commit hash for LLVM head
|
||||
run: >
|
||||
curl --fail --show-error -XPATCH
|
||||
"-HAuthorization: Bearer ${{ secrets.RELEASE_TOKEN }}"
|
||||
"https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}"
|
||||
"-d" '{"draft": true}'
|
||||
- name: Persist release info
|
||||
uses: actions/upload-artifact@v1
|
||||
COMMIT=$(curl --fail --show-error
|
||||
"https://api.github.com/repos/llvm/llvm-project/commits/main" |
|
||||
jq ".sha" -r)
|
||||
|
||||
echo "LLVM_COMMIT=$COMMIT" >> $GITHUB_ENV
|
||||
- name: Compute release info
|
||||
run: |
|
||||
echo "RELEASE_COMMIT_SHORT=$(printf '%.12s' ${{ env.LLVM_COMMIT }})" >> $GITHUB_ENV
|
||||
echo "RELEASE_DATE=$(date -u +%Y%m%d)" >> $GITHUB_ENV
|
||||
echo "LLVM_REPO=llvm/llvm-project" >> commit.env
|
||||
echo "LLVM_COMMIT=${{ env.LLVM_COMMIT }}" >> commit.env
|
||||
- name: Use date as the tag name
|
||||
run: >
|
||||
echo "TAG_NAME=snapshot_${{ env.RELEASE_DATE }}" >> commit.env
|
||||
- name: Use date and release commit as release name
|
||||
run: >
|
||||
echo "RELEASE_NAME=${{ env.RELEASE_DATE }} @${{ env.RELEASE_COMMIT_SHORT }}" >> commit.env
|
||||
- name: Generate default release description
|
||||
run: >
|
||||
echo "RELEASE_DESCRIPTION=Unstable snapshot of clangd on ${{ env.RELEASE_DATE }}." >> commit.env
|
||||
- name: Upload result
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: env
|
||||
path: commit.env
|
||||
workflow_dispatch_environment:
|
||||
name: Use inputs to create build environment
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
steps:
|
||||
- name: Use repo and commit from the inputs
|
||||
run: |
|
||||
echo "LLVM_REPO=${{ github.event.inputs.repo }}" >> commit.env
|
||||
echo "LLVM_COMMIT=${{ github.event.inputs.commit }}" >> commit.env
|
||||
echo "TAG_NAME=${{ github.event.inputs.tag }}" >> commit.env
|
||||
echo "RELEASE_NAME=${{ github.event.inputs.release_name }}" >> commit.env
|
||||
echo "RELEASE_DESCRIPTION=${{ github.event.inputs.description }}" >> commit.env
|
||||
- name: Upload result
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: env
|
||||
path: commit.env
|
||||
create_release:
|
||||
name: Create release
|
||||
runs-on: ubuntu-latest
|
||||
needs: [schedule_environment, workflow_dispatch_environment]
|
||||
# Use always() and manually check results here since GitHub Actions do not
|
||||
# support conditionally skipping jobs and there is no way to "exit with
|
||||
# success" from a job.
|
||||
if: always() && (needs.schedule_environment.result == 'success' || needs.workflow_dispatch_environment.result == 'success')
|
||||
steps:
|
||||
- name: Fetch environment variables
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name:
|
||||
env
|
||||
- name: Set environment variables
|
||||
run: |
|
||||
cat env/commit.env >> $GITHUB_ENV
|
||||
- name: Create release
|
||||
uses: actions/create-release@master
|
||||
id: create_release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ env.TAG_NAME }}
|
||||
release_name: ${{ env.RELEASE_NAME }}
|
||||
body: |
|
||||
${{ env.RELEASE_DESCRIPTION }}
|
||||
|
||||
Built from ${{ env.LLVM_REPO }}@${{ env.LLVM_COMMIT }}.
|
||||
prerelease: true
|
||||
draft: true
|
||||
- name: Preserve release info
|
||||
run: |
|
||||
echo "UPLOAD_URL=${{ steps.create_release.outputs.upload_url }}" >> release.env
|
||||
echo "TAG_NAME=${{ env.TAG_NAME }}" >> release.env
|
||||
echo "RELEASE_ID=${{ steps.create_release.outputs.id }}" >> release.env
|
||||
- name: Upload result
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: release
|
||||
path: commit.env
|
||||
path: release.env
|
||||
# Build clangd using CMake/Ninja.
|
||||
#
|
||||
# This step is a template that runs on each OS, build config varies slightly.
|
||||
# Uploading releases needs a per-job token that expires after an hour.
|
||||
build:
|
||||
name: Build ${{ matrix.config.name }}
|
||||
needs: prepare
|
||||
needs: create_release
|
||||
if: always() && needs.create_release.result == 'success'
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@ -108,7 +210,7 @@ jobs:
|
||||
path: grpc
|
||||
# We use the same version of gRPC for LLVM's clangd-ubuntu-tsan
|
||||
# buildbot.
|
||||
# https://github.com/llvm/llvm-zorg/blob/master/buildbot/google/docker/buildbot-clangd-ubuntu-clang/Dockerfile
|
||||
# https://github.com/llvm/llvm-zorg/blob/main/buildbot/google/docker/buildbot-clangd-ubuntu-clang/Dockerfile
|
||||
ref: v1.36.3
|
||||
submodules: recursive
|
||||
- name: Build gRPC
|
||||
@ -128,11 +230,25 @@ jobs:
|
||||
ninja -C grpc-build install
|
||||
- name: Fetch target commit
|
||||
uses: actions/download-artifact@v1
|
||||
with: { name: release }
|
||||
- name: Set target commit
|
||||
with:
|
||||
name:
|
||||
env
|
||||
- name: Fetch release info
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name:
|
||||
release
|
||||
- name: Put release info into env
|
||||
run: |
|
||||
cat release/commit.env >> $GITHUB_ENV
|
||||
echo "CLANGD_DIR=clangd_${{ github.event.release.tag_name }}" >> $GITHUB_ENV
|
||||
cat env/commit.env >> $GITHUB_ENV
|
||||
cat release/release.env >> $GITHUB_ENV
|
||||
shell: bash
|
||||
# Use environment variables set above to create a directory. This needs
|
||||
# to be a separate step because they are not in the context yet when
|
||||
# being set.
|
||||
- name: Set build directory
|
||||
run: |
|
||||
echo "CLANGD_DIR=clangd_${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
- name: Clone LLVM
|
||||
uses: actions/checkout@v2
|
||||
@ -179,18 +295,20 @@ jobs:
|
||||
${{ env.CLANGD_DIR }}/lib/clang
|
||||
- name: Upload clangd asset
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
env: { GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}" }
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_name: clangd-${{ matrix.config.name }}-${{ github.event.release.tag_name }}.zip
|
||||
upload_url: ${{ env.UPLOAD_URL }}
|
||||
asset_name: clangd-${{ matrix.config.name }}-${{ env.TAG_NAME }}.zip
|
||||
asset_path: clangd.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload indexing-tools asset
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
env: { GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}" }
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_name: clangd_indexing_tools-${{ matrix.config.name }}-${{ github.event.release.tag_name }}.zip
|
||||
upload_url: ${{ env.UPLOAD_URL }}
|
||||
asset_name: clangd_indexing_tools-${{ matrix.config.name }}-${{ env.TAG_NAME }}.zip
|
||||
asset_path: indexing-tools.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Check binary compatibility
|
||||
@ -200,10 +318,19 @@ jobs:
|
||||
finalize:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: always() && needs.build.result == 'success'
|
||||
steps:
|
||||
- name: Fetch release info
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name:
|
||||
release
|
||||
- name: Update the env variables
|
||||
run: >
|
||||
cat release/release.env >> $GITHUB_ENV
|
||||
- name: Publish release
|
||||
run: >
|
||||
curl -XPATCH
|
||||
"-HAuthorization: Bearer ${{ secrets.RELEASE_TOKEN }}"
|
||||
"https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}"
|
||||
"https://api.github.com/repos/${{ github.repository }}/releases/${{ env.RELEASE_ID }}"
|
||||
"-d" '{"draft": false}'
|
||||
|
60
.github/workflows/periodic.yaml
vendored
60
.github/workflows/periodic.yaml
vendored
@ -1,60 +0,0 @@
|
||||
# Workflow to create an auto-buildable release periodically.
|
||||
#
|
||||
# Releases created with automation credentials don't trigger workflows.
|
||||
# Therefore a token `secrets.RELEASE_TOKEN` must exist with public_repo scope.
|
||||
name: Periodic release
|
||||
on:
|
||||
# Run weekly on sunday at 21:37 UTC (arbitrary)
|
||||
schedule:
|
||||
- cron: '37 21 * * SUN'
|
||||
# Allow triggering manually:
|
||||
# curl -XPOST -d '{"event_type":"periodic"}' \
|
||||
# "-HAuthorization: Bearer <token>" \
|
||||
# https://api.github.com/repos/clangd/clangd/dispatches
|
||||
repository_dispatch: { types: periodic }
|
||||
jobs:
|
||||
# Choose the commit to build a release from.
|
||||
#
|
||||
# We want to avoid unbuildable revisions: choose the last green from CI.
|
||||
# FIXME: the criteria should be some consistent set of buildbots passing.
|
||||
pick:
|
||||
name: Create draft release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install jq
|
||||
- name: Clone scripts
|
||||
uses: actions/checkout@v2
|
||||
# Use clangd/actions/pick after
|
||||
# https://github.com/ramasilveyra/last-successful-gh-commit/issues/2 has
|
||||
# been addressed.
|
||||
- name: Get commit hash for LLVM head
|
||||
run: >
|
||||
curl --fail --show-error
|
||||
"-HAuthorization: Bearer ${{ secrets.RELEASE_TOKEN }}"
|
||||
"https://api.github.com/repos/llvm/llvm-project/commits/main" |
|
||||
jq ".sha" -r > commit
|
||||
- name: Compute release info
|
||||
run: |
|
||||
echo "RELEASE_COMMIT=$(cat commit)" >> $GITHUB_ENV
|
||||
echo "RELEASE_COMMIT_SHORT=$(printf '%.12s' $(cat commit))" >> $GITHUB_ENV
|
||||
echo "RELEASE_DATE=$(date -u +%Y%m%d)" >> $GITHUB_ENV
|
||||
- name: Create release
|
||||
uses: actions/create-release@master
|
||||
id: release
|
||||
env: { GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}" }
|
||||
with:
|
||||
tag_name: snapshot_${{ env.RELEASE_DATE }}
|
||||
release_name: ${{ env.RELEASE_DATE }} @${{ env.RELEASE_COMMIT_SHORT }}
|
||||
body: |
|
||||
Unstable snapshot of clangd on ${{ env.RELEASE_DATE }}.
|
||||
|
||||
Built from llvm/llvm-project@${{ env.RELEASE_COMMIT }}.
|
||||
prerelease: true
|
||||
# It would be nice to use draft releases, to hide them from users.
|
||||
# But drafts don't fire events to trigger the autobuild workflow.
|
||||
# Instead, that workflow marks the release as draft until it's built.
|
||||
# As a result, the empty release will be briefly visible to users.
|
||||
draft: false
|
||||
|
Loading…
Reference in New Issue
Block a user