Skip to content

Commit

Permalink
[CI] Refactor Validate Flags workflow (#793)
Browse files Browse the repository at this point in the history
* Check out the Crystal repo associated with the target branch (`release/1.14` for `release/1.14`).
* Run workflow only on `ubuntu-latest`. There's no reason to run this on different platforms. `crystal tool flags` operates on the raw source code and does not take platform differences into account.
* Run workflow only when `docs/syntax_and_semantics/compile_time_flags.md` is changed to avoid noise in unrelated PRs
  • Loading branch information
straight-shoota authored Nov 8, 2024
1 parent 6b34835 commit 6ae7893
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/validate-content.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
name: Validate content
on:
push:
paths:
- docs/syntax_and_semantics/compile_time_flags.md
- .github/workflows/validate-content.yml
pull_request:
branches: [master, release/*]
paths:
- docs/syntax_and_semantics/compile_time_flags.md
- .github/workflows/validate-content.yml
schedule:
- cron: '0 5 * * 1' # Every Monday 5 AM UTC

jobs:
validate-flags:
name: Validate flags
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: macos-latest
- os: windows-latest
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: Download source
uses: actions/checkout@v4
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: nightly
- name: Download crystal repo
uses: actions/checkout@v4
with:
repository: crystal-lang/crystal
path: crystal
# If the PR goes against a release branch, we checkout that same release
# branch in the Crystal repo (names are identical).
ref: ${{ (startsWith(github.base_ref, 'release/') && github.base_ref) || 'master' }}
- name: Run test script
run: scripts/validate-flags.sh
env:
STDLIB_SRC: ./crystal/src
12 changes: 8 additions & 4 deletions scripts/validate-flags.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#! /bin/sh
#! /bin/bash

set -eu
set -eu -o pipefail

CRYSTAL=${CRYSTAL:-crystal}
CRYSTAL_PATH="$($CRYSTAL env CRYSTAL_PATH)"
STDLIB_SRC="${CRYSTAL_PATH#*:}" # stdlib source directory is the last entry in CRYSTAL_PATH
if [ -z "${STDLIB_SRC-}" ]; then
CRYSTAL_PATH="$($CRYSTAL env CRYSTAL_PATH)"
STDLIB_SRC="${CRYSTAL_PATH#*:}" # stdlib source directory is the last entry in CRYSTAL_PATH
fi

echo "Validating flags for stdlib source ${STDLIB_SRC} ($(cat "${STDLIB_SRC}/VERSION"))"

filter_missing() {
missing=0
Expand Down

0 comments on commit 6ae7893

Please sign in to comment.