Skip to content

feat(logs): pro-rate billing for rows removed by drop rules #164271

feat(logs): pro-rate billing for rows removed by drop rules

feat(logs): pro-rate billing for rows removed by drop rules #164271

Workflow file for this run

# This workflow is derived from cargo-dist's generated release workflow:
# https://opensource.axo.dev/cargo-dist/
# It is maintained manually because Release CLI owns publishing.
#
# Copyright 2022-2024, axodotdev
# SPDX-License-Identifier: MIT or Apache-2.0
#
# CI that checks cargo-dist packaging for pull requests.
name: Release
permissions:
contents: read
env:
CARGO_DIST_VERSION: 0.32.0
CARGO_DIST_INSTALLER_SHA256: b657cf8c04a8b7bc28f39d220f7e6dd11bbd2bdb072c552262bd9ccf597261b5
# Publishing is handled by the Release CLI workflow after Release environment approval.
on:
pull_request:
jobs:
# Run 'dist plan' (or host) to determine what tasks we need to do
plan:
runs-on: 'ubuntu-22.04'
timeout-minutes: 10
outputs:
val: ${{ steps.plan.outputs.manifest }}
tag: ''
tag-flag: ''
publishing: 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Install dist
shell: bash
run: |
installer="$RUNNER_TEMP/cargo-dist-installer.sh"
curl --proto '=https' --tlsv1.2 -LsSf \
"https://github.com/axodotdev/cargo-dist/releases/download/v${CARGO_DIST_VERSION}/cargo-dist-installer.sh" \
-o "$installer"
if command -v sha256sum >/dev/null 2>&1; then
echo "${CARGO_DIST_INSTALLER_SHA256} $installer" | sha256sum -c -
elif command -v shasum >/dev/null 2>&1; then
actual="$(shasum -a 256 "$installer" | awk '{print $1}')"
if [ "$actual" != "$CARGO_DIST_INSTALLER_SHA256" ]; then
echo "::error::cargo-dist installer checksum mismatch"
echo "expected: $CARGO_DIST_INSTALLER_SHA256"
echo "actual: $actual"
exit 1
fi
else
echo "::error::No sha256 checksum tool available"
exit 1
fi
sh "$installer"
- name: Cache dist
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cargo-dist-cache
path: ~/.cargo/bin/dist
# sure would be cool if github gave us proper conditionals...
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
# functionality based on whether this is a pull_request, and whether it's from a fork.
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
# but also really annoying to build CI around when it needs secrets to work right.)
- id: plan
env:
DIST_COMMAND: plan
run: |
dist $DIST_COMMAND --output-format=json > plan-dist-manifest.json
echo "dist ran successfully"
cat plan-dist-manifest.json
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
- name: 'Upload dist-manifest.json'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: artifacts-plan-dist-manifest
path: plan-dist-manifest.json
# Build and packages all the platform-specific things
build-local-artifacts:
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
# Let the initial task tell us to not run (currently very blunt)
needs:
- plan
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload' && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository) }}
strategy:
fail-fast: false
# Target platforms/runners are computed by dist in create-release.
# Each member of the matrix has the following arguments:
#
# - runner: the github runner
# - dist-args: cli flags to pass to dist
# - install-dist: expression to run to install dist on the runner
#
# Typically there will be:
# - 1 "global" task that builds universal installers
# - N "local" tasks that build each platform's binaries and platform-specific installers
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
container: ${{ matrix.container && matrix.container.image || null }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
POSTHOG_API_TOKEN: ${{ secrets.POSTHOG_API_TOKEN }}
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
steps:
- name: enable windows longpaths
run: |
git config --global core.longpaths true
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Install Rust
if: ${{ matrix.container }}
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
with:
toolchain: 1.91.1
components: cargo
- name: Install dist
shell: bash
run: |
installer="$RUNNER_TEMP/cargo-dist-installer.sh"
curl --proto '=https' --tlsv1.2 -LsSf \
"https://github.com/axodotdev/cargo-dist/releases/download/v${CARGO_DIST_VERSION}/cargo-dist-installer.sh" \
-o "$installer"
if command -v sha256sum >/dev/null 2>&1; then
echo "${CARGO_DIST_INSTALLER_SHA256} $installer" | sha256sum -c -
elif command -v shasum >/dev/null 2>&1; then
actual="$(shasum -a 256 "$installer" | awk '{print $1}')"
if [ "$actual" != "$CARGO_DIST_INSTALLER_SHA256" ]; then
echo "::error::cargo-dist installer checksum mismatch"
echo "expected: $CARGO_DIST_INSTALLER_SHA256"
echo "actual: $actual"
exit 1
fi
else
echo "::error::No sha256 checksum tool available"
exit 1
fi
sh "$installer"
# Get the dist-manifest
- name: Fetch local artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
pattern: artifacts-*
path: target/distrib/
merge-multiple: true
- name: Install dependencies
run: |
${{ matrix.packages_install }}
- name: Build artifacts
run: |
# Actually do builds and make zips and whatnot
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
echo "dist ran successfully"
- id: cargo-dist
name: Post-build
# We force bash here just because github makes it really hard to get values up
# to "real" actions without writing to env-vars, and writing to env-vars has
# inconsistent syntax between shell and powershell.
shell: bash
run: |
# Parse out what we just built and upload it to scratch storage
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
- name: 'Upload artifacts'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
path: |
${{ steps.cargo-dist.outputs.paths }}
${{ env.BUILD_MANIFEST_NAME }}
# Build and package all the platform-agnostic(ish) things
build-global-artifacts:
needs:
- plan
- build-local-artifacts
runs-on: 'ubuntu-22.04'
timeout-minutes: 15
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
POSTHOG_API_TOKEN: ${{ secrets.POSTHOG_API_TOKEN }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Install cached dist
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: cargo-dist-cache
path: ~/.cargo/bin/
- run: chmod +x ~/.cargo/bin/dist
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
- name: Fetch local artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
pattern: artifacts-*
path: target/distrib/
merge-multiple: true
- id: cargo-dist
shell: bash
run: |
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
echo "dist ran successfully"
# Parse out what we just built and upload it to scratch storage
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
- name: 'Upload artifacts'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: artifacts-build-global
path: |
${{ steps.cargo-dist.outputs.paths }}
${{ env.BUILD_MANIFEST_NAME }}