From 07dd9f58c9cafe8547cb7e9497f60f329eff4c64 Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Sat, 12 Oct 2024 15:39:00 +0100 Subject: [PATCH 1/5] Playing around with reusable workflows --- .github/workflows/ci.yml | 32 ++--------------- .github/workflows/launch_services.yml | 51 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/launch_services.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 710db8291..ae92d835f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -130,37 +130,11 @@ jobs: browser-backend: ["electron", "chrome", "firefox"] steps: - - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Set some environment variables for CI containers pre-build - run: | - cp webapp/.env.test_e2e .env - echo "PYDATALAB_TESTING=true" >> pydatalab/.env + - uses: actions/checkout@v4 - - name: Load previously built Docker images - uses: docker/bake-action@v5 - with: - files: docker-compose.yml - load: true - targets: 'app,api,database' - set: | - app.cache-to=type=gha,scope=build-app,mode=max - app.cache-from=type=gha,scope=build-app - app.tags=datalab-app:latest - api.cache-to=type=gha,scope=build-api,mode=max - api.cache-from=type=gha,scope=build-api - api.tags=datalab-api:latest - database.cache-to=type=gha,scope=build-database,mode=max - database.cache-from=type=gha,scope=build-database - database.tags=datalab-database:latest - - - name: Start services - run: | - # Launch production container profiles and wait for them to come up - docker compose up database api app --no-build --force-recreate -d --wait + - name: Start test servers + uses: ./.github/workflows/launch_services.yml@ml-evs/refactor-ci - name: Run end-to-end tests uses: cypress-io/github-action@v6 diff --git a/.github/workflows/launch_services.yml b/.github/workflows/launch_services.yml new file mode 100644 index 000000000..2112900b6 --- /dev/null +++ b/.github/workflows/launch_services.yml @@ -0,0 +1,51 @@ +name: Start datalab test services + +on: + workflow_call: + inputs: + ref: + description: The commit or tag to run the test server from + type: string + # Using the current commit by default; if called from outside this repo, the SHA will not exist, so will fallback to `main` + default: ${{ github.sha }} +jobs: + start-services: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + repository: datalab-org/datalab + path: /opt/datalab + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Set some environment variables for CI containers pre-build + working-directory: /opt/datalab + run: | + cp webapp/.env.test_e2e .env + echo "PYDATALAB_TESTING=true" >> pydatalab/.env + + - name: Load previously built Docker images + uses: docker/bake-action@v5 + with: + files: /opt/datalab/docker-compose.yml + load: true + targets: 'app,api,database' + set: | + app.cache-to=type=gha,scope=build-app,mode=max + app.cache-from=type=gha,scope=build-app + app.tags=datalab-app:latest + api.cache-to=type=gha,scope=build-api,mode=max + api.cache-from=type=gha,scope=build-api + api.tags=datalab-api:latest + database.cache-to=type=gha,scope=build-database,mode=max + database.cache-from=type=gha,scope=build-database + database.tags=datalab-database:latest + + - name: Start services + working-directory: /opt/datalab + run: | + # Launch production container profiles and wait for them to come up + docker compose up database api app --no-build --force-recreate -d --wait From 8b6328b22311a77f3b08cece4e007b1913dcc7ea Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Sat, 12 Oct 2024 15:43:43 +0100 Subject: [PATCH 2/5] Call reusable workflow from current SHA --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae92d835f..7e153cc85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,7 +134,7 @@ jobs: - uses: actions/checkout@v4 - name: Start test servers - uses: ./.github/workflows/launch_services.yml@ml-evs/refactor-ci + uses: ./.github/workflows/launch_services.yml@${{ github.sha }} - name: Run end-to-end tests uses: cypress-io/github-action@v6 From 454fcc70f297930f28c859ef362aac703200a304 Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Sat, 12 Oct 2024 15:47:34 +0100 Subject: [PATCH 3/5] Tweak --- .github/workflows/ci.yml | 2 +- .github/workflows/launch_services.yml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e153cc85..acad96ada 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,7 +134,7 @@ jobs: - uses: actions/checkout@v4 - name: Start test servers - uses: ./.github/workflows/launch_services.yml@${{ github.sha }} + uses: ./.github/workflows/launch_services.yml - name: Run end-to-end tests uses: cypress-io/github-action@v6 diff --git a/.github/workflows/launch_services.yml b/.github/workflows/launch_services.yml index 2112900b6..aec60e41d 100644 --- a/.github/workflows/launch_services.yml +++ b/.github/workflows/launch_services.yml @@ -3,18 +3,18 @@ name: Start datalab test services on: workflow_call: inputs: - ref: - description: The commit or tag to run the test server from - type: string + # ref: + # description: The commit or tag to run the test server from + # type: string # Using the current commit by default; if called from outside this repo, the SHA will not exist, so will fallback to `main` - default: ${{ github.sha }} + # default: ${{ github.sha }} jobs: start-services: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: - ref: ${{ inputs.ref }} + # ref: ${{ inputs.ref }} repository: datalab-org/datalab path: /opt/datalab From 811e45bdc5c2c518cff0789af7b7f88af3efe389 Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Sat, 12 Oct 2024 15:51:58 +0100 Subject: [PATCH 4/5] Try removing .yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acad96ada..2dea0d2f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,7 +134,7 @@ jobs: - uses: actions/checkout@v4 - name: Start test servers - uses: ./.github/workflows/launch_services.yml + uses: ./.github/workflows/launch_services - name: Run end-to-end tests uses: cypress-io/github-action@v6 From cb5d914cb1ed7753e22a04d3af8b8c7d140f7ab8 Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Sat, 12 Oct 2024 15:54:53 +0100 Subject: [PATCH 5/5] Try quoting --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2dea0d2f6..a3c9d278e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -132,9 +132,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Start test servers - uses: ./.github/workflows/launch_services + uses: './.github/workflows/launch_services.yml' - name: Run end-to-end tests uses: cypress-io/github-action@v6