diff --git a/.github/actions/edgedb-setup/action.yml b/.github/actions/edgedb-setup/action.yml index 35ee93daa3..c08b34a7a6 100644 --- a/.github/actions/edgedb-setup/action.yml +++ b/.github/actions/edgedb-setup/action.yml @@ -1,10 +1,26 @@ name: Setup EdgeDB description: 'Setup EdgeDB server, migrate schema, generate TS files' + runs: using: composite steps: - name: Setup EdgeDB uses: edgedb/setup-edgedb@v1 + with: + cli-version: nightly + server-version: none + + - name: Branch & Migrate + shell: bash + run: | + echo "Creating branch $BRANCH" + edgedb branch create $BRANCH + echo "Switching to branch $BRANCH" + edgedb branch switch $BRANCH + echo "Applying new migrations to branch $BRANCH" + edgedb migrate + env: + BRANCH: github_${{ github.event.number }}_${{ env.GITHUB_RUN_ID }}_${{ env.GITHUB_RUN_ATTEMPT }}_${{ env.GITHUB_JOB }} - name: Generate EdgeDB TS files shell: bash diff --git a/.github/actions/edgedb-teardown/action.yml b/.github/actions/edgedb-teardown/action.yml new file mode 100644 index 0000000000..0d028705b1 --- /dev/null +++ b/.github/actions/edgedb-teardown/action.yml @@ -0,0 +1,13 @@ +name: Teardown EdgeDB +runs: + using: composite + steps: + - name: Delete Branch + shell: bash + run: | + echo "Switching to main" + edgedb branch switch main + echo "Dropping branch $BRANCH" + edgedb branch drop $BRANCH --non-interactive + env: + BRANCH: github_${{ github.event.number }}_${{ env.GITHUB_RUN_ID }}_${{ env.GITHUB_RUN_ATTEMPT }}_${{ env.GITHUB_JOB }} diff --git a/.github/workflows/api-schema.yml b/.github/workflows/api-schema.yml index 7472fb0c18..9c222aa5c6 100644 --- a/.github/workflows/api-schema.yml +++ b/.github/workflows/api-schema.yml @@ -7,6 +7,10 @@ on: - synchronize - labeled +env: + EDGEDB_INSTANCE: ${{ secrets.EDGEDB_INSTANCE }} + EDGEDB_SECRET_KEY: ${{ secrets.EDGEDB_SECRET_KEY }} + jobs: generate: name: Generate @@ -34,6 +38,10 @@ jobs: name: ${{ matrix.ref }}-gql-schema path: schema.graphql + - name: EdgeDB Teardown + uses: ./.github/actions/edgedb-teardown + if: always() + graphql-diff: name: GraphQL Diff needs: [generate] diff --git a/.github/workflows/edgedb.yml b/.github/workflows/edgedb.yml index 0d7a7eb770..1daa803a2a 100644 --- a/.github/workflows/edgedb.yml +++ b/.github/workflows/edgedb.yml @@ -2,6 +2,10 @@ name: EdgeDB on: pull_request: +env: + EDGEDB_INSTANCE: ${{ secrets.EDGEDB_INSTANCE }} + EDGEDB_SECRET_KEY: ${{ secrets.EDGEDB_SECRET_KEY }} + jobs: Clean: runs-on: ubuntu-latest @@ -10,11 +14,8 @@ jobs: - name: Node Setup & Yarn Install uses: ./.github/actions/setup - - uses: edgedb/setup-edgedb@v1 - - - name: Generate EdgeDB TS files - shell: bash - run: yarn edgedb:gen + - name: EdgeDB Setup + uses: ./.github/actions/edgedb-setup - name: Inject Access Policies run: yarn console edgedb ap inject @@ -26,3 +27,7 @@ jobs: - name: Validate seed scripts are error free run: yarn edgedb:seed shell: bash + + - name: EdgeDB Teardown + uses: ./.github/actions/edgedb-teardown + if: always() diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6c36b4d8ef..b518365484 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,6 +6,10 @@ on: - master - develop +env: + EDGEDB_INSTANCE: ${{ secrets.EDGEDB_INSTANCE }} + EDGEDB_SECRET_KEY: ${{ secrets.EDGEDB_SECRET_KEY }} + jobs: lint: runs-on: ubuntu-latest @@ -34,3 +38,7 @@ jobs: - name: Lint run: yarn eslint --ext .ts,.tsx --max-warnings 0 . + + - name: EdgeDB Teardown + uses: ./.github/actions/edgedb-teardown + if: always() diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 051c9c4724..baa42ffa0b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,10 @@ on: - master - develop +env: + EDGEDB_INSTANCE: ${{ secrets.EDGEDB_INSTANCE }} + EDGEDB_SECRET_KEY: ${{ secrets.EDGEDB_SECRET_KEY }} + jobs: Unit: runs-on: ubuntu-latest @@ -21,6 +25,10 @@ jobs: - name: Tests run: yarn test --reporters=github-actions + - name: EdgeDB Teardown + uses: ./.github/actions/edgedb-teardown + if: always() + E2E: name: E2E Tests (${{ matrix.database }} ${{ matrix.shard }}/6) runs-on: ubuntu-latest @@ -65,3 +73,7 @@ jobs: NEO4J_VERSION: ${{ matrix.neo4j-version }} DATABASE: ${{ matrix.database }} continue-on-error: ${{ matrix.database == 'edgedb' }} + + - name: EdgeDB Teardown + uses: ./.github/actions/edgedb-teardown + if: always()