Skip to content

Commit

Permalink
Update rust toolchain validation steps (#371)
Browse files Browse the repository at this point in the history
* use stable

* update RELEASE to include full test command

* don't pass +stable to cargo, let the rustc version be inferred

* update RELEASE notes

* update rust verification flow to fit new requirements

* fix ci by ensuring rust toolchain override is in place

* validate rust environment in ci

* hopefully fixing the ci tests

* remove debug ci step

* remove obsolete code

* appease staticcheck

* add double verbose flags for debugging

* use rustup show active-toolchain

* add missing information omitted from prior PRs

* fix ci

* update code and tests to reflect the need to avoid non-stable environments

* use go 1.17 for the module and run 'go mod tidy'

* simplify summary of logic

* remove double verbose cargo flag

* update messaging after a round of manual testing
  • Loading branch information
Integralist authored Sep 2, 2021
1 parent 3fbc526 commit 1daf152
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 185 deletions.
21 changes: 7 additions & 14 deletions .github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
go-version: 1.17.x
- name: "Restore golang bin cache"
id: go-bin-cache
uses: actions/cache@v2
Expand Down Expand Up @@ -53,9 +53,9 @@ jobs:
test:
strategy:
matrix:
go-version: [1.16.x]
go-version: [1.17.x]
node-version: [12]
rust-toolchain: [1.54.0]
rust-toolchain: [stable]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down Expand Up @@ -87,17 +87,9 @@ jobs:
toolchain: ${{ matrix.rust-toolchain }}
- name: "Add wasm32-wasi Rust target"
run: rustup target add wasm32-wasi --toolchain ${{ matrix.rust-toolchain }}
- name: "Restore cargo cache"
uses: actions/cache@v2
with:
path: |
~/.rustup/
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: "Validate Rust toolchain"
run: rustup show && rustup target list --installed --toolchain stable
shell: bash
- name: "Install Node"
uses: actions/setup-node@v2
with:
Expand All @@ -111,3 +103,4 @@ jobs:
env:
TEST_COMPUTE_INIT: true
TEST_COMPUTE_BUILD: true
TEST_COMPUTE_DEPLOY: true
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

1. Merge all PRs intended for the release.
2. Rebase latest remote main branch locally (`git pull --rebase origin main`).
3. Ensure all analysis checks and tests are passing (`make all`).
3. Ensure all analysis checks and tests are passing (`time TEST_COMPUTE_INIT=1 TEST_COMPUTE_BUILD=1 TEST_COMPUTE_DEPLOY=1 make all`).
4. Open a new PR to update CHANGELOG ([example](https://github.com/fastly/cli/pull/273))<sup>[1](#note1)</sup>.
5. Merge CHANGELOG.
6. Rebase latest remote main branch locally (`git pull --rebase origin main`).
Expand Down
3 changes: 2 additions & 1 deletion TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ Some integration tests aren't run outside of the CI environment, to enable these
The available environment variables are:

- `TEST_COMPUTE_INIT`: runs `TestInit`.
- `TEST_COMPUTE_BUILD`: runs `TestBuildRust` and `TestBuildAssemblyScript`.
- `TEST_COMPUTE_BUILD`: runs `TestBuildRust`, `TestBuildAssemblyScript` and `TestBuildJavaScript`.
- `TEST_COMPUTE_BUILD_RUST`: runs `TestBuildRust`.
- `TEST_COMPUTE_BUILD_ASSEMBLYSCRIPT`: runs `TestBuildAssemblyScript`.
- `TEST_COMPUTE_BUILD_JAVASCRIPT`: runs `TestBuildJavaScript`.
- `TEST_COMPUTE_DEPLOY`: runs `TestDeploy`.

**Example**:
Expand Down
18 changes: 17 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/fastly/cli

go 1.16
go 1.17

require (
github.com/Masterminds/semver/v3 v3.1.0
Expand Down Expand Up @@ -32,3 +32,19 @@ require (
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)

require (
github.com/andybalholm/brotli v0.0.0-20190621154722-5f990b63d2d6 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/jsonapi v0.0.0-20201022225600-f822737867f6 // indirect
github.com/klauspost/compress v1.9.2 // indirect
github.com/klauspost/pgzip v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/nwaples/rardecode v1.0.0 // indirect
github.com/ulikunitz/xz v0.5.6 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b // indirect
)
24 changes: 10 additions & 14 deletions pkg/commands/compute/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestBuildRust(t *testing.T) {
Language: config.Language{
Rust: config.Rust{
ToolchainVersion: "1.49.0",
ToolchainConstraint: ">= 1.49.0 < 2.0.0",
ToolchainConstraint: ">= 1.54.0",
WasmWasiTarget: "wasm32-wasi",
FastlySysConstraint: "0.0.0",
RustupConstraint: ">= 1.23.0",
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestBuildRust(t *testing.T) {
Language: config.Language{
Rust: config.Rust{
ToolchainVersion: "1.49.0",
ToolchainConstraint: ">= 1.49.0 < 2.0.0",
ToolchainConstraint: ">= 1.54.0",
WasmWasiTarget: "wasm32-wasi",
FastlySysConstraint: "0.0.0",
RustupConstraint: ">= 1.23.0",
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestBuildRust(t *testing.T) {
Language: config.Language{
Rust: config.Rust{
ToolchainVersion: "1.49.0",
ToolchainConstraint: ">= 1.49.0 < 2.0.0",
ToolchainConstraint: ">= 1.54.0",
WasmWasiTarget: "wasm32-wasi",
FastlySysConstraint: ">= 0.4.0 <= 0.9.0", // the fastly-sys version in 0.6.0 is actually ^0.3.6 so a minimum of 0.4.0 causes the constraint to fail
RustupConstraint: ">= 1.23.0",
Expand Down Expand Up @@ -200,13 +200,8 @@ func TestBuildRust(t *testing.T) {
applicationConfig: config.File{
Language: config.Language{
Rust: config.Rust{
// NOTE: my local rust environment has versions 1.[45|46|49|54].0
// So I've set the constraint to ensure the test fails.
// Example, the code logic will select 1.54.0, which is outside the constraint limit 1.40.0
//
// The .github/workflows/pr_test.yml should have the same version
// 1.54.0 set which should align with the constraint defined in the
// CLI's dynamic config.
// NOTE: A 'stable' release will fail the constraint, which is set
// to something lower than current stable.
ToolchainVersion: "1.0.0",
ToolchainConstraint: ">= 1.0.0 < 1.40.0",
WasmWasiTarget: "wasm32-wasi",
Expand All @@ -218,8 +213,8 @@ func TestBuildRust(t *testing.T) {
client: versionClient{
fastlyVersions: []string{"0.6.0"},
},
wantError: "rust toolchain 1.54.0 is incompatible with the constraint >= 1.0.0 < 1.40.0",
wantRemediationError: "To fix this error, run the following command with a version within the given range >= 1.0.0 < 1.40.0:\n\n\t$ rustup toolchain install <version>\n",
wantError: "rustc constraint '>= 1.0.0 < 1.40.0' not met: 1.54.0",
wantRemediationError: "Run `rustup update stable`, or ensure your `rust-toolchain` file specifies a version matching the constraint (e.g. `channel = \"stable\"`).",
},
{
name: "fastly crate prerelease",
Expand All @@ -232,7 +227,7 @@ func TestBuildRust(t *testing.T) {
Language: config.Language{
Rust: config.Rust{
ToolchainVersion: "1.49.0",
ToolchainConstraint: ">= 1.49.0 < 2.0.0",
ToolchainConstraint: ">= 1.54.0",
WasmWasiTarget: "wasm32-wasi",
FastlySysConstraint: ">= 0.3.0 <= 0.6.0",
RustupConstraint: ">= 1.23.0",
Expand Down Expand Up @@ -266,7 +261,7 @@ func TestBuildRust(t *testing.T) {
Language: config.Language{
Rust: config.Rust{
ToolchainVersion: "1.49.0",
ToolchainConstraint: ">= 1.49.0 < 2.0.0",
ToolchainConstraint: ">= 1.54.0",
WasmWasiTarget: "wasm32-wasi",
FastlySysConstraint: ">= 0.3.0 <= 0.6.0",
RustupConstraint: ">= 1.23.0",
Expand Down Expand Up @@ -336,6 +331,7 @@ func TestBuildRust(t *testing.T) {
opts.ConfigFile = testcase.applicationConfig
opts.HTTPClient = testcase.client
err = app.Run(opts)
t.Log(stdout.String())
testutil.AssertErrorContains(t, err, testcase.wantError)
testutil.AssertRemediationErrorContains(t, err, testcase.wantRemediationError)
if testcase.wantOutputContains != "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/compute/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ func TestDeploy(t *testing.T) {
err = app.Run(opts)
}

// t.Log(stdout.String())
t.Log(stdout.String())

testutil.AssertErrorContains(t, err, testcase.wantError)

Expand Down
Loading

0 comments on commit 1daf152

Please sign in to comment.