Skip to content

Commit

Permalink
Merge branch 'main' into additional_search_views/VByLine
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Nov 26, 2023
2 parents 8a3f717 + f56ad17 commit 0688cee
Show file tree
Hide file tree
Showing 46 changed files with 3,678 additions and 836 deletions.
10 changes: 6 additions & 4 deletions .github/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ group:
- source: automations/data/
dest: automations/data/
# Synced workflows
- source: .github/workflows/new_issues.yml
dest: .github/workflows/new_issues.yml
- source: .github/workflows/new_prs.yml
dest: .github/workflows/new_prs.yml
- source: .github/workflows/issue_automations.yml
dest: .github/workflows/issue_automations.yml
- source: .github/workflows/pr_automations.yml
dest: .github/workflows/pr_automations.yml
- source: .github/workflows/pr_automations_init.yml
dest: .github/workflows/pr_automations_init.yml
- source: .github/workflows/label_new_pr.yml
dest: .github/workflows/label_new_pr.yml
- source: .github/workflows/pr_label_check.yml
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/issue_automations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Runs all automations related to issue events.
#
# See `pr_automations_init.yml` and `pr_automations.yml` for the corresponding
# implementation for PRs.
name: Issue automations

on:
issues:
types:
- opened
- reopened
- closed
- assigned
- labeled
- unlabeled

jobs:
run:
name: Perform issue automations
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Perform issue automations
uses: actions/github-script@v7
env:
EVENT_NAME: ${{ github.event_name }}
EVENT_ACTION: ${{ github.event.action }}
with:
github-token: ${{ secrets.ACCESS_TOKEN }}
script: |
const { main } = await import('${{ github.workspace }}/automations/js/src/project_automation/issues.mjs')
await main(github, context)
30 changes: 0 additions & 30 deletions .github/workflows/new_issues.yml

This file was deleted.

74 changes: 74 additions & 0 deletions .github/workflows/pr_automations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Runs all automations related to PR events.
#
# See `issue_automations.yml` for the corresponding implementation for issues.
#
# The automations for PR events are a little more complex than those for issues
# because PRs are a less secure environment. To avoid leaking secrets, we need
# to run automations with code as it appears on `main`.
#
# `pull_request_target` serves this purpose but there is no corresponding
# `_target` version for `pull_request_review`. So we take this roundabout
# approach:
#
# This workflow waits for the `pr_automations_init.yml` workflow to complete and
# then uses its exports to run automations from main, with access to secrets.
#
# ...continued from `pr_automations_init.yml`
#
# 4. This workflow runs after `pr_automations_init.yml` workflow completes.
# 5. It downloads the artifacts from that workflow run.
# 6. It extracts the JSON file from the ZIP to `/tmp`.
# 7. It runs the automations as a script, which can access secrets.

name: PR automations

on:
workflow_run:
workflows:
- PR automations init
types:
- completed

jobs:
run:
name: Perform PR automations
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

# This step was copied from the GitHub docs.
# Ref: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
- name: Download artifact
uses: actions/github-script@v7
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "event_info"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/event_info.zip`, Buffer.from(download.data));
- name: Unzip artifact
run: |
unzip event_info.zip
mv event.json /tmp/event.json
- name: Perform PR automations
uses: actions/github-script@v7
with:
github-token: ${{ secrets.ACCESS_TOKEN }}
script: |
const { main } = await import('${{ github.workspace }}/automations/js/src/project_automation/prs.mjs')
await main(github)
50 changes: 50 additions & 0 deletions .github/workflows/pr_automations_init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Initialises all automations related to PR events.
#
# See `issue_automations.yml` for the corresponding implementation for issues.
#
# The automations for PR events are a little more complex than those for issues
# because PRs are a less secure environment. To avoid leaking secrets, we need
# to run automations with code as it appears on `main`.
#
# `pull_request_target` serves this purpose but there is no corresponding
# `_target` version for `pull_request_review`. So we take this roundabout
# approach:
#
# 1. This workflow runs for the events and their subtypes we are interested in.
# 2. It saves the event name, action and PR node ID to a JSON file.
# 3. It uploads the JSON file as an artifact.
# 4. Its completion triggers the `pr_automations.yml` workflow.
#
# continued in `pr_automations.yml`...

name: PR automations init

on:
pull_request:
types:
- opened
- reopened
- edited
- converted_to_draft
- ready_for_review
- closed
pull_request_review:

jobs:
run:
name: Save event info
runs-on: ubuntu-latest
steps:
- name: Save event info
run: |
echo '{"eventName": "'"$EVENT_NAME"'", "eventAction": "'"$EVENT_ACTION"'", "prNodeId": "'"$PR_NODE_ID"'"}' > /tmp/event.json
env:
EVENT_NAME: ${{ github.event_name }}
EVENT_ACTION: ${{ github.event.action }}
PR_NODE_ID: ${{ github.event.pull_request.node_id }}

- name: Upload event info as artifact
uses: actions/upload-artifact@v3
with:
name: event_info
path: /tmp/event.json
6 changes: 4 additions & 2 deletions api/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ pytest-sugar = "~=0.9"
pook = {ref = "master", git = "git+https://github.com/h2non/pook.git"}

[packages]
adrf = "~=0.1.2"
aiohttp = "~=3.8"
aws-requests-auth = "~=0.4"
deepdiff = "~=6.4"
Django = "~=4.2"
django-asgi-lifespan = "~=0.1"
django-cors-headers = "~=4.2"
django-log-request-id = "~=2.0"
django-oauth-toolkit = "~=2.3"
django-redis = "~=5.4"
django-split-settings = "*"
django-tqdm = "~=1.3"
django-uuslug = "~=2.0"
djangorestframework = "~=3.14"
Expand All @@ -35,11 +38,10 @@ elasticsearch-dsl = "~=8.9"
future = "~=0.18"
limit = "~=0.2"
Pillow = "~=10.1.0"
psycopg = "~=3.1"
python-decouple = "~=3.8"
python-xmp-toolkit = "~=2.0"
sentry-sdk = "~=1.30"
django-split-settings = "*"
psycopg = "~=3.1"
uvicorn = {extras = ["standard"], version = "~=0.23"}

[requires]
Expand Down
Loading

0 comments on commit 0688cee

Please sign in to comment.