Skip to content
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

bring CI up to date with ngrok-rust #22

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading