-
Notifications
You must be signed in to change notification settings - Fork 0
Add CI workflow and composite setup action #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,101 @@ | ||||||||||||||||||||||||
| name: ci-setup | ||||||||||||||||||||||||
| description: "Composite action to install Erlang/rebar3 and Gleam (pinned) and restore Gleam cache" | ||||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||||
| otp-version: | ||||||||||||||||||||||||
| description: 'OTP version' | ||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||
| default: '28.1' | ||||||||||||||||||||||||
| rebar3-version: | ||||||||||||||||||||||||
| description: 'rebar3 version' | ||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||
| default: '3.25.1' | ||||||||||||||||||||||||
| gleam-version: | ||||||||||||||||||||||||
| description: 'Gleam version' | ||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||
| default: '1.13.0' | ||||||||||||||||||||||||
| arch: | ||||||||||||||||||||||||
| description: 'Architecture for Gleam asset' | ||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||
| default: 'linux-x86_64' | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| runs: | ||||||||||||||||||||||||
| using: "composite" | ||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||
| - name: Restore Gleam cache | ||||||||||||||||||||||||
| uses: actions/cache@v4 | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| path: ~/.cache/gleam | ||||||||||||||||||||||||
| key: ${{ runner.os }}-gleam-${{ hashFiles('**/gleam.toml') }} | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Install Erlang/OTP, rebar3 and (optionally) Gleam | ||||||||||||||||||||||||
| uses: erlef/setup-beam@v1 | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| otp-version: ${{ inputs.otp-version }} | ||||||||||||||||||||||||
| rebar3-version: ${{ inputs.rebar3-version }} | ||||||||||||||||||||||||
| gleam-version: ${{ inputs.gleam-version }} | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Ensure Gleam is installed (fallbacks) | ||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||
| GLEAM_VERSION: ${{ inputs.gleam-version }} | ||||||||||||||||||||||||
| ARCH: ${{ inputs.arch }} | ||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||
| set -eux | ||||||||||||||||||||||||
| # If erlef/setup-beam already provided gleam, we're done | ||||||||||||||||||||||||
| if command -v gleam >/dev/null 2>&1; then | ||||||||||||||||||||||||
| echo "gleam already installed" | ||||||||||||||||||||||||
| gleam --version || true | ||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
| TAG="v${GLEAM_VERSION}" | ||||||||||||||||||||||||
| API_URL="https://api.github.com/repos/gleam-lang/gleam/releases/tags/${TAG}" | ||||||||||||||||||||||||
| echo "Querying ${API_URL} for assets" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Try exact-match first (version+arch) | ||||||||||||||||||||||||
| DOWNLOAD_URL=$(curl -fsSL "${API_URL}" \ | ||||||||||||||||||||||||
| | grep -oE '"browser_download_url":\s*"[^"]+' \ | ||||||||||||||||||||||||
| | sed -E 's/.*"([^\"]+)$/\1/' \ | ||||||||||||||||||||||||
| | grep "${GLEAM_VERSION}-${ARCH}" || true) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # If not found, try any linux/x86_64-ish asset | ||||||||||||||||||||||||
| if [ -z "${DOWNLOAD_URL}" ]; then | ||||||||||||||||||||||||
| echo "Exact asset not found; searching for any linux/x86_64 asset" | ||||||||||||||||||||||||
| DOWNLOAD_URL=$(curl -fsSL "${API_URL}" \ | ||||||||||||||||||||||||
| | grep -oE '"browser_download_url":\s*"[^"]+' \ | ||||||||||||||||||||||||
| | sed -E 's/.*"([^\"]+)$/\1/' \ | ||||||||||||||||||||||||
| | grep -Ei "linux|x86|x86_64|amd64" | head -n1 || true) | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if [ -n "${DOWNLOAD_URL}" ]; then | ||||||||||||||||||||||||
| echo "Found asset: ${DOWNLOAD_URL}" | ||||||||||||||||||||||||
| curl -fsSL -o /tmp/gleam.tar.gz "${DOWNLOAD_URL}" | ||||||||||||||||||||||||
| tar -xzf /tmp/gleam.tar.gz -C /usr/local/bin --strip-components=1 | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| tar -xzf /tmp/gleam.tar.gz -C /usr/local/bin --strip-components=1 | |
| mkdir -p "$HOME/.local/bin" | |
| tar -xzf /tmp/gleam.tar.gz -C "$HOME/.local/bin" --strip-components=1 | |
| export PATH="$HOME/.local/bin:$PATH" |
Copilot
AI
Nov 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The rustup installation script is piped directly to sh without verification. While this is the official installation method, it poses a security risk if the source is compromised. Consider adding a checksum verification or using a pinned version of the installer script.
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
| # Download rustup installer script | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup-init.sh | |
| # Verify SHA256 hash (update this hash if the installer script changes) | |
| EXPECTED_HASH="REPLACE_WITH_KNOWN_GOOD_HASH" | |
| ACTUAL_HASH="$(sha256sum /tmp/rustup-init.sh | awk '{print $1}')" | |
| if [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then | |
| echo "rustup-init.sh hash mismatch! Aborting." | |
| exit 1 | |
| fi | |
| sh /tmp/rustup-init.sh -y |
Copilot
AI
Nov 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback build copies the binary to $HOME/.cargo/bin/ but doesn't ensure this directory exists first. If rustup was just installed, the directory should exist, but if cargo was already present, this path might not exist. Consider adding mkdir -p "$HOME/.cargo/bin" before the copy operation to ensure it succeeds.
| cargo build --release | |
| cargo build --release | |
| mkdir -p "$HOME/.cargo/bin" |
Copilot
AI
Nov 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PATH is exported within the script but these exports only affect the current shell session. In GitHub Actions composite actions, PATH modifications need to be persisted to subsequent steps using echo "$HOME/.cargo/bin" >> $GITHUB_PATH. Without this, the Gleam binary installed via cargo will not be accessible in the parent workflow's subsequent steps.
| export PATH="$HOME/.cargo/bin:$PATH" | |
| export PATH="$HOME/.cargo/bin:$PATH" | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,68 @@ | ||||||||||||||||||||||||
| name: CI | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||
| branches: [ main, master ] | ||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||
| branches: [ main, master ] | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||
| run-tests: | ||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Setup runtime | ||||||||||||||||||||||||
| uses: ./.github/actions/ci-setup | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| otp-version: '28.1' | ||||||||||||||||||||||||
| rebar3-version: '3.25.1' | ||||||||||||||||||||||||
| gleam-version: '1.13.0' | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Cache Gleam deps and build | ||||||||||||||||||||||||
| uses: actions/cache@v4 | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| path: | | ||||||||||||||||||||||||
| ~/.cache/gleam | ||||||||||||||||||||||||
| ~/.gleam | ||||||||||||||||||||||||
| ./_gleam_deps | ||||||||||||||||||||||||
| ./build | ||||||||||||||||||||||||
| key: ${{ runner.os }}-gleam-1.13.0-otp28-cache-${{ hashFiles('**/gleam.toml') }} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| restore-keys: | | ||||||||||||||||||||||||
| ${{ runner.os }}-gleam-1.13.0-otp28-cache- | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+23
to
+34
|
||||||||||||||||||||||||
| - name: Cache Gleam deps and build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/gleam | |
| ~/.gleam | |
| ./_gleam_deps | |
| ./build | |
| key: ${{ runner.os }}-gleam-1.13.0-otp28-cache-${{ hashFiles('**/gleam.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gleam-1.13.0-otp28-cache- |
Copilot
AI
Nov 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The artifact step always creates test-success.txt with "tests: ok" even if the tests actually failed. Since if: always() is used, this file will be created and uploaded regardless of test outcome, which could be misleading. Consider only creating this file when tests succeed, or include the actual test status in the artifact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Gleam binary is downloaded via curl without verifying checksums or signatures. This could pose a security risk if the download is compromised or redirected. Consider verifying the downloaded artifact against published checksums or signatures from the Gleam releases page.