diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index b943db14..00000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Benchmark -on: - push: - branches: - - main - -permissions: - contents: write - deployments: write - -jobs: - benchmark: - name: Run Benchmark - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - # - run: rustup toolchain update nightly && rustup default nightly - - name: Run benchmark - run: cargo bench -- --output-format bencher | tee output.txt # +nightly - - - name: Store benchmark result - uses: benchmark-action/github-action-benchmark@v1 - with: - name: Rust Benchmark - tool: "cargo" - output-file-path: output.txt - github-token: ${{ secrets.GITHUB_TOKEN }} - auto-push: true - # Show alert with commit comment on detecting possible performance regression - alert-threshold: "200%" - comment-on-alert: true - fail-on-alert: true - alert-comment-cc-users: "@johnnymorganz" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 0b28bb79..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Test StyLua -on: - push: - branches: - - main - pull_request: - branches: - - main -jobs: - test_default: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Test (default) - run: cargo test - - test_no_default_features: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Test (default) - run: cargo test --no-default-features - - test_luau: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Test (Luau) - run: cargo test --features luau - - test_lua52: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Test (Lua 5.2) - run: cargo test --features lua52 - - test_lua53: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Test (Lua 5.3) - run: cargo test --features lua53 - - test_lua54: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Test (Lua 5.4) - run: cargo test --features lua54 - - test_luajit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Test (LuaJIT) - run: cargo test --features luajit - - test_all_features: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Test (all features) - run: cargo test --all-features - - test_wasm: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Test Build (wasm) - run: | - rustup target add wasm32-unknown-unknown - cargo check --target wasm32-unknown-unknown --features luau,lua52,lua53,lua54,luajit - - test_wasm_build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - target: wasm32-unknown-unknown - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: "16.x" - registry-url: "https://registry.npmjs.org" - - - name: Test Build (wasm-pack) - run: | - chmod u+x ./wasm/build-wasm.sh - ./wasm/build-wasm.sh - - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Clippy - run: | - cargo clippy --all-features -- -D warnings - - name: Rustfmt - run: | - cargo fmt -- --check diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index c8a40fb1..00000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Code Coverage -on: - push: - branches: - - main - pull_request: - branches: - - main -jobs: - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup toolchain - uses: dtolnay/rust-toolchain@nightly - with: - components: llvm-tools-preview - - # - name: Install grcov - # run: curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - - - # - name: Run tests - # run: cargo test - # env: - # RUSTFLAGS: "-Zinstrument-coverage" - # LLVM_PROFILE_FILE: "report-%p-%m.profraw" - - # - name: Run grcov - # run: ./grcov $(find . -name "report-*.profraw" -print) -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing --ignore "src/cli/*" -o coverage.lcov - - - name: Install cargo-llvm-cov - uses: taiki-e/install-action@cargo-llvm-cov - - - name: Generate code coverage - run: cargo llvm-cov --ignore-filename-regex "src/cli/*" --lcov --output-path lcov.info - - - name: Upload - uses: codecov/codecov-action@v3 - with: - files: lcov.info diff --git a/.github/workflows/extension.yml b/.github/workflows/extension.yml deleted file mode 100644 index c4167583..00000000 --- a/.github/workflows/extension.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: VSCode Extension -on: - push: - branches: - - main - pull_request: - branches: - - main -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version: 16.x - - name: Install dependencies - run: npm ci - working-directory: stylua-vscode - - name: Run ESLint - run: npm run lint - working-directory: stylua-vscode - - name: Prettier - run: npm run check:format - working-directory: stylua-vscode - - build: - strategy: - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 16.x - - run: npm install - working-directory: stylua-vscode - - run: xvfb-run -a npm test - working-directory: stylua-vscode - if: runner.os == 'Linux' - - run: npm test - working-directory: stylua-vscode - if: runner.os != 'Linux' diff --git a/.github/workflows/large-scale-test.yml b/.github/workflows/large-scale-test.yml deleted file mode 100644 index edc82a4b..00000000 --- a/.github/workflows/large-scale-test.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: Measure Diff Across Multiple Repos -on: - workflow_dispatch: - inputs: - prId: - description: "PR #" - required: true - type: number - type: - description: "Diff computation type" - required: true - default: "diffAfterMainFormat" - type: choice - options: - - diffAfterMainFormat # format using main branch first, then apply PR changes ontop of that - - diffMainVsChangeFormat # format using main branch, store. Reset to original then format using PR branch. Compute differences - -jobs: - build-latest: - name: Build Pull Request (#${{ github.event.inputs.prId }}) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Checkout Pull Request - run: gh pr checkout ${{ github.event.inputs.prId }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Build (All features) - run: cargo build --verbose --locked --release --all-features - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: stylua-latest - path: target/release/stylua - - build-main: - name: Build Main - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: "main" - - - name: Build (All features) - run: cargo build --verbose --locked --release --all-features - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: stylua-main - path: target/release/stylua - - run-comparison: - runs-on: ubuntu-latest - needs: ["build-main", "build-latest"] - steps: - - uses: actions/checkout@v4 - - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - path: artifacts - - - name: Set up artifacts - run: | - mv ./artifacts/stylua-main/stylua ./stylua-main - mv ./artifacts/stylua-latest/stylua ./stylua-latest - - - name: Run comparison tool - id: run_comparison - run: | - body="$(python ./.github/run_comparisons.py ${{ github.event.inputs.type }})" - body="${body//'%'/'%25'}" - body="${body//$'\n'/'%0A'}" - body="${body//$'\r'/'%0D'}" - echo "::set-output name=body::$body" - - - name: Create comment - uses: peter-evans/create-or-update-comment@v3 - with: - issue-number: ${{ github.event.inputs.prId }} - body: ${{ steps.run_comparison.outputs.body }} diff --git a/.github/workflows/npm-build.yml b/.github/workflows/npm-build.yml deleted file mode 100644 index 4b40a4ad..00000000 --- a/.github/workflows/npm-build.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: NPM Packaging -on: - push: - branches: - - main - pull_request: - branches: - - main -jobs: - # Ensure it builds on all platforms - smoketest: - strategy: - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version: 16.x - - name: Attempt install - run: npm install --package-locked - working-directory: stylua-npm-bin - - name: Attempt run - run: npx . --version - working-directory: stylua-npm-bin diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 949ecff7..48a4aed8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,28 +2,13 @@ name: Release on: push: - tags: ["*"] + tags: ["v*-1"] workflow_dispatch: jobs: - create-release: - name: Create Release - runs-on: ubuntu-latest - outputs: - upload_url: ${{ steps.create_release.outputs.upload_url }} - steps: - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - draft: true - release: - needs: ["create-release"] + permissions: + contents: write strategy: matrix: include: @@ -64,7 +49,7 @@ jobs: sudo apt install ${{ matrix.linker }} - name: Build Binary (All features) - run: cargo build --verbose --locked --release --features lua52,lua53,lua54,luau,luajit --target ${{ matrix.cargo-target }} + run: cargo build --verbose --locked --release --features lua52,lua53,lua54,luajit --target ${{ matrix.cargo-target }} env: CARGO_TARGET_DIR: output @@ -76,125 +61,18 @@ jobs: if [ "${{ matrix.os }}" = "windows-latest" ]; then cp "output/${{ matrix.cargo-target }}/release/stylua.exe" staging/ cd staging - 7z a ../release.zip * + 7z a ../${{ matrix.artifact-name }}.zip * else cp "output/${{ matrix.cargo-target }}/release/stylua" staging/ cd staging - zip ../release.zip * + zip ../${{ matrix.artifact-name }}.zip * fi - - name: Upload Binary Artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.artifact-name }} - path: release.zip - - name: Upload Binary to Release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_path: release.zip - asset_name: ${{ matrix.artifact-name }}.zip - asset_content_type: application/zip - - release_cargo: - name: Publish to cargo - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Publish to cargo - run: cargo publish --verbose --locked --token ${{ secrets.CARGO_TOKEN }} - - release_npm_wasm: - name: Publish wasm to npm - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - target: wasm32-unknown-unknown - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: "16.x" - registry-url: "https://registry.npmjs.org" - - - name: Build WASM - run: | - chmod u+x ./wasm/build-wasm.sh - ./wasm/build-wasm.sh - - - name: Publish to npm - working-directory: wasm - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - release_npm_bin: - name: Publish binary to npm - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: "16.x" - registry-url: "https://registry.npmjs.org" - - - name: Setup README and LICENSE - run: | - cp README.md stylua-npm-bin/ - cp LICENSE.md stylua-npm-bin/ - - - name: Publish to npm - working-directory: stylua-npm-bin - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - release_docker: - name: Publish image to container registry - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: docker/setup-buildx-action@v3 - id: buildx - with: - install: true - - - uses: docker/metadata-action@v5 - id: meta - env: - DOCKER_METADATA_PR_HEAD_SHA: "true" - with: - images: johnnymorganz/stylua - tags: | - type=semver,pattern={{version}} - type=sha - - - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - uses: docker/build-push-action@v5 + if: startsWith(github.ref, 'refs/tags/v') + id: create_release + uses: ncipollo/release-action@v1 with: - push: true - context: . - file: Dockerfile - builder: ${{ steps.buildx.outputs.name }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha + allowUpdates: true + artifacts: ${{ matrix.artifact-name }}.zip + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-cases.yml b/.github/workflows/test-cases.yml deleted file mode 100644 index 22549293..00000000 --- a/.github/workflows/test-cases.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Pull Latest Test Cases -on: - workflow_dispatch: - schedule: - - cron: "10 0 * * *" # Runs at 00:10 UTC every day - -jobs: - retrieve_cases: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Pull latest tests - run: python ./.github/retrieve_test_cases.py - - - name: Update insta snapshots - run: | - cargo install cargo-insta - CI=false cargo insta test --accept - CI=false cargo insta test --features lua52 --accept - CI=false cargo insta test --features lua53 --accept - CI=false cargo insta test --features lua54 --accept - CI=false cargo insta test --features luau --accept - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - with: - title: Update external test cases - body: | - Pulls in new changes from external repositories for test cases - - This pull request is **auto-generated** - branch: auto/update-external-test-cases - commit-message: Update external test cases - base: main