feat: Add forgejo_personal_access_token resource. #810
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Terraform Provider testing workflow. | |
| name: Tests | |
| # This GitHub action runs your tests for each pull request and push. | |
| # Optionally, you can turn it on using a schedule for regular testing. | |
| on: | |
| pull_request: | |
| paths-ignore: | |
| - "README.md" | |
| push: | |
| paths-ignore: | |
| - "README.md" | |
| # Testing only needs permissions to read the repository contents. | |
| permissions: | |
| contents: read | |
| jobs: | |
| # Ensure project builds before running testing matrix | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Go | |
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | |
| with: | |
| go-version-file: "go.mod" | |
| cache: true | |
| - name: Download Go modules | |
| run: go mod download | |
| - name: Compile Go package | |
| run: go build -v . | |
| - name: Run linters | |
| uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 | |
| with: | |
| version: latest | |
| generate: | |
| name: Generate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Go | |
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | |
| with: | |
| go-version-file: "go.mod" | |
| cache: true | |
| # We need the latest version of Terraform for our documentation generation to use | |
| - name: Set up Terraform | |
| uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1 | |
| with: | |
| terraform_wrapper: false | |
| - name: Generate documentation | |
| run: make generate | |
| - name: Check for differences | |
| run: | | |
| git diff --compact-summary --exit-code || \ | |
| (echo; echo "Unexpected difference in directories after code generation. Run 'make generate' command and commit."; exit 1) | |
| # Run acceptance tests in a matrix with Terraform CLI versions | |
| test-terraform: | |
| name: Terraform Provider Acceptance Tests | |
| needs: build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # list whatever Terraform versions here you would like to support | |
| terraform: | |
| - "1.15.*" | |
| - "1.14.*" | |
| - "1.13.*" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Go | |
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | |
| with: | |
| go-version-file: "go.mod" | |
| cache: true | |
| - name: Set up Terraform | |
| uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1 | |
| with: | |
| terraform_version: ${{ matrix.terraform }} | |
| terraform_wrapper: false | |
| - name: Set up Docker Compose | |
| uses: docker/setup-compose-action@4eb059ff7f16592f9c84d5ca339c53cb7c5064e2 #v2.3.0 | |
| - name: Start Forgejo server | |
| working-directory: ./docker | |
| run: | | |
| docker compose pull --quiet | |
| docker compose up --no-start | |
| docker run --rm -v docker_forgejo:/data alpine mkdir -p /data/gitea/conf | |
| docker compose cp app.ini forgejo:/data/gitea/conf/app.ini | |
| docker compose start | |
| - name: Wait for 30 seconds | |
| run: sleep 30s | |
| - name: Create admin user | |
| id: admin | |
| working-directory: ./docker | |
| run: > | |
| echo "password=$(docker compose exec -u git forgejo | |
| /usr/local/bin/forgejo admin user create | |
| --username tfadmin | |
| --email tfadmin@localhost | |
| --random-password | |
| --admin | grep 'generated' | cut -d ' ' -f 5 | tr -d \')" >> "$GITHUB_OUTPUT" | |
| - name: Generate admin token | |
| id: token | |
| working-directory: ./docker | |
| run: > | |
| echo "token=$(docker compose exec -u git forgejo | |
| /usr/local/bin/forgejo admin user generate-access-token | |
| --username tfadmin | |
| --scopes write:organization,write:repository,write:user,write:admin | |
| --raw)" >> "$GITHUB_OUTPUT" | |
| - name: Download Go modules | |
| run: go mod download | |
| - name: Run acceptance tests | |
| env: | |
| TF_ACC: "1" | |
| TF_VAR_FORGEJO_BASIC_AUTH_USERNAME: tfadmin | |
| TF_VAR_FORGEJO_BASIC_AUTH_PASSWORD: ${{ steps.admin.outputs.password }} | |
| FORGEJO_API_TOKEN: ${{ steps.token.outputs.token }} | |
| run: go test -v -cover ./internal/provider/ | |
| timeout-minutes: 10 | |
| test-opentofu: | |
| name: OpenTofu Provider Acceptance Tests | |
| needs: build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # list whatever OpenTofu versions here you would like to support | |
| opentofu: | |
| - "1.12.*" | |
| - "1.11.*" | |
| - "1.10.*" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Go | |
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | |
| with: | |
| go-version-file: "go.mod" | |
| cache: true | |
| - name: Set up OpenTofu | |
| uses: opentofu/setup-opentofu@a1320f892987e89d278cc92dc5adc984fb93aca4 # v2.0.2 | |
| with: | |
| tofu_version: ${{ matrix.opentofu }} | |
| tofu_wrapper: false | |
| - name: Set up Docker Compose | |
| uses: docker/setup-compose-action@4eb059ff7f16592f9c84d5ca339c53cb7c5064e2 #v2.3.0 | |
| - name: Start Forgejo server | |
| working-directory: ./docker | |
| run: | | |
| docker compose pull --quiet | |
| docker compose up --no-start | |
| docker run --rm -v docker_forgejo:/data alpine mkdir -p /data/gitea/conf | |
| docker compose cp app.ini forgejo:/data/gitea/conf/app.ini | |
| docker compose start | |
| - name: Wait for 30 seconds | |
| run: sleep 30s | |
| - name: Create admin user | |
| id: admin | |
| working-directory: ./docker | |
| run: > | |
| echo "password=$(docker compose exec -u git forgejo | |
| /usr/local/bin/forgejo admin user create | |
| --username tfadmin | |
| --email tfadmin@localhost | |
| --random-password | |
| --admin | grep 'generated' | cut -d ' ' -f 5 | tr -d \')" >> "$GITHUB_OUTPUT" | |
| - name: Generate admin token | |
| id: token | |
| working-directory: ./docker | |
| run: > | |
| echo "token=$(docker compose exec -u git forgejo | |
| /usr/local/bin/forgejo admin user generate-access-token | |
| --username tfadmin | |
| --scopes write:organization,write:repository,write:user,write:admin | |
| --raw)" >> "$GITHUB_OUTPUT" | |
| - name: Download Go modules | |
| run: go mod download | |
| - name: Run acceptance tests | |
| env: | |
| TF_ACC: "1" | |
| TF_VAR_FORGEJO_BASIC_AUTH_USERNAME: tfadmin | |
| TF_VAR_FORGEJO_BASIC_AUTH_PASSWORD: ${{ steps.admin.outputs.password }} | |
| FORGEJO_API_TOKEN: ${{ steps.token.outputs.token }} | |
| run: go test -v -cover ./internal/provider/ | |
| timeout-minutes: 10 |