Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/ci-build-speed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@googleworkspace/cli": patch
---

Speed up CI builds with Swatinem/rust-cache, sccache, and build artifact reuse for smoketests
90 changes: 52 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,13 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.7

- name: Cache cargo
uses: actions/cache@v4
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: test-${{ matrix.os }}

- name: Run tests
run: cargo test --verbose
Expand All @@ -61,6 +58,14 @@ jobs:
with:
components: rustfmt, clippy

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.7

- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: lint

- name: Check formatting
run: |
if ! cargo fmt --all -- --check; then
Expand Down Expand Up @@ -104,16 +109,13 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.7

- name: Cache cargo
uses: actions/cache@v4
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-skills-${{ hashFiles('**/Cargo.lock') }}
key: skills

- name: Regenerate skills
run: cargo run -- generate-skills --output-dir skills
Expand All @@ -134,6 +136,10 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: coverage
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
Expand Down Expand Up @@ -163,6 +169,14 @@ jobs:
with:
targets: ${{ matrix.target }}

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.7

- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: build-${{ matrix.target }}

- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
Expand All @@ -174,29 +188,29 @@ jobs:
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc

- name: Upload binary
if: matrix.target == 'x86_64-unknown-linux-gnu'
uses: actions/upload-artifact@v4
with:
name: gws-linux-x86_64
path: target/x86_64-unknown-linux-gnu/release/gws
retention-days: 1

smoketest:
name: API Smoketest
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo
uses: actions/cache@v4
- name: Download binary
uses: actions/download-artifact@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-smoketest-${{ hashFiles('**/Cargo.lock') }}
name: gws-linux-x86_64
path: ./bin

- name: Build
run: cargo build --release
- name: Make binary executable
run: chmod +x ./bin/gws

- name: Decode credentials
env:
Expand All @@ -209,48 +223,48 @@ jobs:
echo "$GOOGLE_CREDENTIALS_JSON" | base64 -d > /tmp/credentials.json

- name: Smoketest — help
run: ./target/release/gws --help
run: ./bin/gws --help

- name: Smoketest — schema introspection
run: ./target/release/gws schema drive.files.list | jq -e '.httpMethod'
run: ./bin/gws schema drive.files.list | jq -e '.httpMethod'

- name: Smoketest — Drive files list
env:
GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE: /tmp/credentials.json
run: |
./target/release/gws drive files list \
./bin/gws drive files list \
--params '{"pageSize": 1, "fields": "files(id,mimeType)"}' \
| jq -e '.files'

- name: Smoketest — Gmail messages
env:
GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE: /tmp/credentials.json
run: |
./target/release/gws gmail users messages list \
./bin/gws gmail users messages list \
--params '{"userId": "me", "maxResults": 1, "fields": "messages(id)"}' \
| jq -e '.messages'

- name: Smoketest — Calendar events
env:
GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE: /tmp/credentials.json
run: |
./target/release/gws calendar events list \
./bin/gws calendar events list \
--params '{"calendarId": "primary", "maxResults": 1, "fields": "kind,items(id,status)"}' \
| jq -e '.kind'

- name: Smoketest — Slides presentation
env:
GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE: /tmp/credentials.json
run: |
./target/release/gws slides presentations get \
./bin/gws slides presentations get \
--params '{"presentationId": "1knOKD_87JWE4qsEbO4r5O91IxTER5ybBBhOJgZ1yLFI", "fields": "presentationId,slides(objectId)"}' \
| jq -e '.presentationId'

- name: Smoketest — pagination
env:
GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE: /tmp/credentials.json
run: |
LINES=$(./target/release/gws drive files list \
LINES=$(./bin/gws drive files list \
--params '{"pageSize": 1, "fields": "nextPageToken,files(id)"}' \
--page-all --page-limit 2 \
| wc -l)
Expand All @@ -261,7 +275,7 @@ jobs:

- name: Smoketest — error handling
run: |
if ./target/release/gws fakeservice list 2>&1; then
if ./bin/gws fakeservice list 2>&1; then
echo "::error::Expected exit code 1 for unknown service"
exit 1
fi
Expand Down
Loading