diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f55993f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# EditorConfig is awesome: https://EditorConfig.org + + +# top-most EditorConfig file +root = true + +[*.yml] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = false +insert_final_newline = false \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edd6983..7439c62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,14 @@ permissions: contents: read jobs: + changes: + uses: ./.github/workflows/filter-changes.yml + permissions: + pull-requests: read + contents: read build: + needs: changes + if: ${{ needs.changes.outputs.ci == 'true' }} && github.repository == 'pagefaultgames/rogueserver' name: Build (${{ matrix.os_name }}) env: GO_VERSION: 1.22 @@ -25,9 +32,9 @@ jobs: - os: windows-latest os_name: windows arch: amd64 -# TODO macos needs universal binary! -# - os: macos-latest -# os_name: macos + # TODO macos needs universal binary! + # - os: macos-latest + # os_name: macos steps: - uses: actions/checkout@v4 - name: Set up Go ${{ env.GO_VERSION }} @@ -43,7 +50,7 @@ jobs: version: latest args: --config .golangci.yml - name: Test - run: go test -v + run: go test -v ./... - name: Build run: go build -v - name: Upload artifact diff --git a/.github/workflows/filter-changes.yml b/.github/workflows/filter-changes.yml new file mode 100644 index 0000000..324cd6f --- /dev/null +++ b/.github/workflows/filter-changes.yml @@ -0,0 +1,38 @@ +name: Path Filters + +on: + workflow_call: + +permissions: + pull-requests: read + contents: read + +jobs: + # JOB to run change detection + changes: + runs-on: ubuntu-latest + # Required permissions + permissions: + pull-requests: read + # Set job outputs to values from filter step + outputs: + ci: ${{ steps.filter.outputs.ci }} + ghcr: ${{ steps.filter.outputs.ghcr }} + steps: + # For pull requests it's not necessary to checkout the code + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + common: &common + - '**/*.go' + - go.mod + - go.sum + ghcr: + - *common + - .dockerignore + - Dockerfile + - docker-compose.Development.yml + ci: + - *common + - .golangci.yml diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 038dba9..9d5a21e 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -10,9 +10,16 @@ permissions: packages: write jobs: + changes: + uses: ./.github/workflows/filter-changes.yml + permissions: + pull-requests: read + contents: read + build: + needs: changes name: Build and publish to GHCR - if: github.repository == 'pagefaultgames/rogueserver' + if: ${{ needs.changes.outputs.ghcr == 'true' }} && github.repository == 'pagefaultgames/rogueserver' env: GO_VERSION: 1.22 runs-on: ubuntu-latest diff --git a/REUSE.toml b/REUSE.toml index 6e45738..0eaabd3 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -12,6 +12,7 @@ path = [ "go.sum", "go.mod", ".github/FUNDING.yml", + "**/*.editorconfig", ] SPDX-FileCopyrightText = "NONE" SPDX-License-Identifier = "CC0-1.0"