From 4a323e83499e55a517accdcf717e810d8bdc1583 Mon Sep 17 00:00:00 2001 From: Danny McGee Date: Fri, 10 May 2024 17:49:13 -0400 Subject: [PATCH] GitHub workflow attempt #3 --- .github/actions/setup-node/action.yml | 20 ++++++ .github/actions/setup-rust/action.yml | 23 +++++++ .github/workflows/pr-validation.yml | 95 +++++++++++++-------------- 3 files changed, 90 insertions(+), 48 deletions(-) create mode 100644 .github/actions/setup-node/action.yml create mode 100644 .github/actions/setup-rust/action.yml diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml new file mode 100644 index 00000000..950b0c9d --- /dev/null +++ b/.github/actions/setup-node/action.yml @@ -0,0 +1,20 @@ +name: Setup Node +runs: + using: composite + steps: + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + - uses: actions/cache@v4 + with: + path: node_modules/ + key: ${{ runner.os }}-setup-node-${{ hashFiles('**/package.json', '**/package-lock.json') }} + - name: Install node dependencies + run: npm ci + - name: Ensure unambiguous `main` + if: github.ref != 'refs/heads/main' + run: | + git remote set-branches origin main + git fetch --depth 1 origin main + git branch main origin/main diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml new file mode 100644 index 00000000..f071ecbb --- /dev/null +++ b/.github/actions/setup-rust/action.yml @@ -0,0 +1,23 @@ +name: Setup Rust +runs: + using: composite + steps: + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-setup-rust-${{ hashFiles('**/Cargo.toml') }} + - name: Set default Rust toolchain + run: rustup default stable + - name: Verify Rust setup + run: rustup show diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index 85b59c0f..fdb38664 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -16,59 +16,58 @@ jobs: # git fetch --depth 1 origin main # git branch main origin/main - setup-rust: - runs-on: ubuntu-latest - # needs: checkout-repo - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-setup-rust-${{ hashFiles('**/Cargo.toml') }} - - name: Set default Rust toolchain - run: rustup default stable - - name: Verify Rust setup - run: rustup show + # setup-rust: + # runs-on: ubuntu-latest + # # needs: checkout-repo + # steps: + # - uses: actions/checkout@v4 + # - uses: dtolnay/rust-toolchain@stable + # with: + # components: clippy + # - uses: dtolnay/rust-toolchain@nightly + # with: + # components: rustfmt + # - uses: actions/cache@v4 + # with: + # path: | + # ~/.cargo/bin/ + # ~/.cargo/registry/index/ + # ~/.cargo/registry/cache/ + # ~/.cargo/git/db/ + # target/ + # key: ${{ runner.os }}-setup-rust-${{ hashFiles('**/Cargo.toml') }} + # - name: Set default Rust toolchain + # run: rustup default stable + # - name: Verify Rust setup + # run: rustup show - setup-node: - runs-on: ubuntu-latest - # needs: checkout-repo - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - - uses: actions/cache@v4 - with: - path: node_modules/ - key: ${{ runner.os }}-setup-node-${{ hashFiles('**/package.json', '**/package-lock.json') }} - - name: Install node dependencies - run: npm ci + # setup-node: + # runs-on: ubuntu-latest + # # needs: checkout-repo + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-node@v4 + # with: + # node-version: 20 + # cache: npm + # - uses: actions/cache@v4 + # with: + # path: node_modules/ + # key: ${{ runner.os }}-setup-node-${{ hashFiles('**/package.json', '**/package-lock.json') }} + # - name: Install node dependencies + # run: npm ci validate-affected: runs-on: ubuntu-latest - needs: - - setup-rust - - setup-node steps: - uses: actions/checkout@v4 - - name: Ensure unambiguous `main` - if: github.ref != 'refs/heads/main' - run: | - git remote set-branches origin main - git fetch --depth 1 origin main - git branch main origin/main + - uses: ./.github/actions/setup-rust + - uses: ./.github/actions/setup-node + # - name: Ensure unambiguous `main` + # if: github.ref != 'refs/heads/main' + # run: | + # git remote set-branches origin main + # git fetch --depth 1 origin main + # git branch main origin/main - name: nx affected run: npx nx affected -t format lint test --configuration ci