Skip to content

Commit

Permalink
Merge pull request #22 from ngrok/josh/update-ci
Browse files Browse the repository at this point in the history
bring CI up to date with ngrok-rust
  • Loading branch information
jrobsonchase authored Oct 14, 2024
2 parents eda83c5 + bb82dbb commit be80c82
Show file tree
Hide file tree
Showing 11 changed files with 385 additions and 1,243 deletions.
124 changes: 124 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
on:
push:
branches: [main]
pull_request:

name: Continuous integration

jobs:
udeps:
name: Udeps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jrobsonchase/[email protected]
- uses: ./.github/workflows/rust-cache
- uses: actions-rs/cargo@v1
with:
command: udeps
args: --workspace --all-targets --all-features

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jrobsonchase/[email protected]
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jrobsonchase/[email protected]
- uses: ./.github/workflows/rust-cache
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --all-features --workspace -- -D warnings

test-nix:
name: Test Nix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jrobsonchase/[email protected]
- uses: ./.github/workflows/rust-cache
- uses: actions-rs/cargo@v1
env:
NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }}
with:
command: test
args: --workspace --all-targets

test-stable:
name: Test Stable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# We don't actualy have sccache installed here (yet), but it still
# benefits from the cargo cache.
- uses: ./.github/workflows/rust-cache
- uses: actions-rs/cargo@v1
env:
NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }}
with:
command: test
args: --workspace --all-targets

test-win:
name: Test Windows Stable
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# We don't actualy have sccache installed here (yet), but it still
# benefits from the cargo cache.
- uses: ./.github/workflows/rust-cache
- uses: actions-rs/cargo@v1
env:
NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }}
with:
command: test
args: --workspace --all-targets

semver:
name: Semver Check
runs-on: ubuntu-latest
strategy:
matrix:
crate: [ngrok-api]
steps:
- uses: actions/checkout@v2
- uses: jrobsonchase/[email protected]
- uses: ./.github/workflows/rust-cache
- uses: actions-rs/cargo@v1
name: semver checks
with:
command: semver-checks
args: check-release -p ${{ matrix.crate }}

publish-ngrok-api:
name: Publish ngrok-api
uses: ./.github/workflows/release.yml
needs: [udeps, fmt, clippy, test-nix, test-stable, test-win, semver]
if: github.ref_name == 'main' && github.repository == 'ngrok/ngrok-api-rs'
permissions:
contents: write
with:
crate: ngrok-api
secrets:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
65 changes: 65 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
on:
push:
branches: [main]

name: Publish Docs

jobs:
build:
name: Build Rustdocs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: install protoc
run: sudo apt-get -o Acquire::Retries=3 install -y protobuf-compiler
- uses: actions-rs/cargo@v1
with:
command: doc
args: --no-deps
- name: Archive docs
shell: sh
run: |
echo "<meta http-equiv=\"refresh\" content=\"0; url=ngrok\">" > target/doc/index.html
chmod -c -R +r target/doc | while read line; do
echo "::warning title=Changed permissions on a file::$line"
done
tar \
--dereference --hard-dereference \
--directory target/doc \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
.
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: github-pages
path: ${{ runner.temp }}/artifact.tar
retention-days: ${{ inputs.retention-days }}

# Deploy job
deploy:
# Add a dependency to the build job
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on:
workflow_dispatch:
inputs:
crate:
description: 'Crate to release'
required: true
default: 'ngrok-api'
workflow_call:
inputs:
crate:
description: 'Crate to release'
required: true
type: string
secrets:
CARGO_REGISTRY_TOKEN:
required: true

name: Release

jobs:
cargo-publish:
name: Publish and Tag
runs-on: ubuntu-latest
permissions:
contents: write
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: jrobsonchase/[email protected]
- name: cargo publish
uses: actions-rs/cargo@v1
with:
command: publish
args: -p ${{ inputs.crate }} --token ${{secrets.CARGO_REGISTRY_TOKEN}}
- name: tag release
run: |
version="$(extract-crate-version ${{inputs.crate}})"
git config user.name "GitHub Action"
git config user.email [email protected]
git tag -a -m "Version ${version}" ${{inputs.crate}}-v${version}
git push --tags
25 changes: 25 additions & 0 deletions .github/workflows/rust-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'rust cache setup'
description: 'Set up cargo and sccache caches'
inputs: {}
outputs: {}
runs:
using: "composite"
steps:
- name: configure sccache
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
core.exportVariable('SCCACHE_GHA_CACHE_TO', 'sccache-${{runner.os}}-${{github.ref_name}}');
core.exportVariable('SCCACHE_GHA_CACHE_FROM', 'sccache-${{runner.os}}-main,sccache-${{runner.os}}-');
- name: cargo registry cache
uses: actions/cache@v3
with:
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-${{ github.sha }}
restore-keys: |
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
cargo-${{ runner.os }}-
path: |
~/.cargo/registry
~/.cargo/git
20 changes: 0 additions & 20 deletions .github/workflows/rust.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/stale-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Close inactive issues
on:
schedule:
- cron: "42 2 * * *"

jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 30
days-before-issue-close: 14
stale-issue-label: "stale"
stale-issue-message: "This issue is stale because it has been open for 30 days with no activity. This issue will be closed in 14 days if still labeled stale."
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/Cargo.lock
/target
/.direnv
/result
/.helix
Loading

0 comments on commit be80c82

Please sign in to comment.