Skip to content

File tree

1 file changed

+16
-156
lines changed

1 file changed

+16
-156
lines changed
Lines changed: 16 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,21 @@
1-
name: build
2-
on: [ push, pull_request ]
1+
name: "Copilot Setup Steps"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- .github/workflows/copilot-setup-steps.yml
8+
pull_request:
9+
paths:
10+
- .github/workflows/copilot-setup-steps.yml
11+
312
jobs:
4-
setup:
13+
copilot-setup-steps:
514
runs-on: ubuntu-22.04
6-
steps:
7-
# Required for workflow triggers like the auto-label for failing PRs
8-
- name: Save PR number
9-
if: github.event_name == 'pull_request'
10-
run: |
11-
mkdir -p ./pr
12-
echo ${{ github.event.number }} > ./pr/NR
13-
- uses: actions/upload-artifact@v4
14-
if: github.event_name == 'pull_request'
15-
with:
16-
name: pr
17-
path: pr/
18-
# Commit branch/name extraction from:
19-
# https://github.community/t/accessing-commit-message-in-pull-request-event/17158/8
20-
#
21-
# We need to fetch more than one commit to be able to access HEAD^2 in case
22-
# of a pull request
23-
- uses: actions/checkout@v4
24-
with:
25-
fetch-depth: 10
26-
# In case of a push event, the commit we care about is simply HEAD.
27-
# The current branch name can be found by parsing GITHUB_REF, for example,
28-
# if we are on the master branch, then GITHUB_REF = refs/heads/master.
29-
- name: Get commit branch and commit message from push
30-
if: github.event_name == 'push'
31-
run: |
32-
echo "BRANCH_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
33-
echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV
34-
echo "$(git log --format=%B -n 1 HEAD)" >> $GITHUB_ENV
35-
echo "EOF" >> $GITHUB_ENV
36-
echo "PREVIOUS_COMMIT=$(git log --format=%H -n 1 HEAD~1)" >> $GITHUB_ENV
37-
# In case of a pull_request event, the commit we care about is HEAD^2, that
38-
# is, the second parent of the pull request merge commit.
39-
# The current branch name is directly given by GITHUB_HEAD_REF
40-
- name: Get commit branch and commit message from PR
41-
if: github.event_name == 'pull_request'
42-
run: |
43-
echo "BRANCH_NAME=$GITHUB_HEAD_REF" >> $GITHUB_ENV
44-
echo "TARGET_BRANCH_NAME=$(echo ${GITHUB_BASE_REF##*/})" >> $GITHUB_ENV
45-
echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV
46-
echo "$(git log --format=%B -n 1 HEAD^2)" >> $GITHUB_ENV
47-
echo "EOF" >> $GITHUB_ENV
48-
echo "PREVIOUS_COMMIT=$(git log --format=%H -n 1 HEAD^2~1)" >> $GITHUB_ENV
49-
- uses: actions/setup-python@v5
50-
with:
51-
python-version: '3.10'
52-
architecture: 'x64'
53-
- name: Get all changes vs master
54-
env:
55-
PR_NUMBER: ${{ github.event.pull_request.number }}
56-
run: |
57-
echo "DIFF<<EOF" >> $GITHUB_ENV
58-
echo "$(./toolset/github_actions/github_actions_diff.py)" >> $GITHUB_ENV
59-
echo "EOF" >> $GITHUB_ENV
60-
- name: Determine which (if any) tests need to be run
61-
run: |
62-
echo "RUN_TESTS<<EOF" >> $GITHUB_ENV
63-
echo "$(grep -oP "github-actions-run-tests \K(.*)" <<< $DIFF || true)" >> $GITHUB_ENV
64-
echo "EOF" >> $GITHUB_ENV
65-
- id: event_out
66-
name: Write event outputs
67-
run: |
68-
# Escape the multiline string for Github Actions, see https://lab.amalitsky.com/posts/2022/github-actions-set-output-migration/#migration-from-set-output-to-github-output
69-
delimiter="$(openssl rand -hex 8)"
70-
{
71-
echo "commit_message<<${delimiter}"
72-
echo $COMMIT_MESSAGE
73-
echo "${delimiter}"
74-
} >> $GITHUB_OUTPUT
75-
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
76-
echo "target_branch_name=$TARGET_BRANCH_NAME" >> $GITHUB_OUTPUT
77-
echo "previous_commit=$PREVIOUS_COMMIT" >> $GITHUB_OUTPUT
78-
- id: verify_out
79-
name: Write verify job matrix
80-
run: |
81-
# Use of jq for JSON array creation from https://stackoverflow.com/a/26809318
82-
# The following creates a JSON object as follows:
83-
# include:
84-
# - TESTLANG: {lang}
85-
# with a TESTLANG object in the include array for each language under frameworks
86-
VERIFY_MATRIX=$(ls -1 frameworks | jq -Rc '.+"/" | select(inside(env.RUN_TESTS)) | rtrimstr("/")' | jq -sc '{include: map({TESTLANG: .})}')
87-
echo "verify_matrix=$VERIFY_MATRIX" >> $GITHUB_OUTPUT
88-
outputs:
89-
commit_message: ${{ steps.event_out.outputs.commit_message }}
90-
branch_name: ${{ steps.event_out.outputs.branch_name }}
91-
target_branch_name: ${{ steps.event_out.outputs.target_branch_name }}
92-
previous_commit: ${{ steps.event_out.outputs.previous_commit }}
93-
verify_matrix: ${{ steps.verify_out.outputs.verify_matrix }}
94-
verify:
95-
needs: setup
96-
# The matrix check is necessary because an empty job matrix is otherwise considered a workflow failure
97-
if: ${{ !contains(needs.setup.outputs.commit_message, '[ci skip]') && contains(needs.setup.outputs.verify_matrix, 'TESTLANG') }}
98-
runs-on: ubuntu-22.04
99-
strategy:
100-
matrix: ${{ fromJSON(needs.setup.outputs.verify_matrix) }}
101-
# Disable fail-fast to allow all failing frameworks/etc to fail in a
102-
# single build, rather than stopping when the first one fails.
103-
fail-fast: false
104-
env:
105-
TESTLANG: ${{ matrix.TESTLANG }}
106-
TESTDIR: ${{ matrix.TESTDIR }}
107-
COMMIT_MESSAGE: ${{ needs.setup.outputs.commit_message }}
108-
BRANCH_NAME: ${{ needs.setup.outputs.branch_name }}
109-
TARGET_BRANCH_NAME: ${{ needs.setup.outputs.target_branch_name }}
110-
PREVIOUS_COMMIT: ${{ needs.setup.outputs.previous_commit }}
111-
PR_NUMBER: ${{ github.event.pull_request.number }}
15+
16+
permissions:
17+
contents: read
18+
11219
steps:
11320
- uses: actions/checkout@v4
11421
with:
@@ -117,29 +24,7 @@ jobs:
11724
with:
11825
python-version: '3.10'
11926
architecture: 'x64'
120-
- name: Get all changes vs master
121-
# Runs github_actions_diff, with the the output accessible in later steps
122-
run: |
123-
# Write the result to env.DIFF for later steps
124-
echo "DIFF<<EOF" >> $GITHUB_ENV
125-
echo "$(./toolset/github_actions/github_actions_diff.py)" >> $GITHUB_ENV
126-
echo "EOF" >> $GITHUB_ENV
127-
- id: should_run_tests
128-
name: Determine which (if any) tests need to be run
129-
# Searches for github-actions-diff-continue to determine if the suite should be installed and the current $TESTDIR test should run.
130-
run: |
131-
# grep returns status code 1 if no matches are found. This fails the
132-
# build as it is a non-zero status. But this is an expected
133-
# possibility, so `|| true` is used to address/silence that.
134-
# Write the result to env.RUN_TESTS for later steps
135-
echo "RUN_TESTS<<EOF" >> $GITHUB_ENV
136-
echo "$(grep -oP "github-actions-run-tests \K(.*)" <<< $DIFF || true)" >> $GITHUB_ENV
137-
echo "EOF" >> $GITHUB_ENV
138-
- name: Log status
139-
run: |
140-
if [ "$RUN_TESTS" ]; then echo "Proceeding to run tests."; else echo 'Skipping test verification.'; fi
14127
- name: Build tfb dockerfile
142-
if: ${{ env.RUN_TESTS }}
14328
uses: mattes/cached-docker-build-action@v1
14429
with:
14530
args: " --file ./Dockerfile --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --tag techempower/tfb ."
@@ -149,28 +34,3 @@ jobs:
14934
run: |
15035
sudo service mysql stop || true
15136
sudo service postgresql stop || true
152-
- name: Run tests if needed
153-
if: ${{ env.RUN_TESTS }}
154-
run: |
155-
# run-ci.py runs the diffing to see if github actions needs to test this framework. Ideally/eventually,
156-
# we'd like to try and do the diffing before github_actions_clean & setup.
157-
# This will run the tests exactly as you would in your own vm:
158-
docker network create tfb > /dev/null 2>&1 && docker run --network=tfb -e USER_ID=$(id -u) -e CI=true -v /var/run/docker.sock:/var/run/docker.sock --mount type=bind,source=`pwd`,target=/FrameworkBenchmarks techempower/tfb --mode verify --force-rm --test-dir $RUN_TESTS --results-environment Github-Actions;
159-
dependabot:
160-
needs: verify
161-
runs-on: ubuntu-latest
162-
permissions:
163-
pull-requests: write
164-
contents: write
165-
if: ${{ github.actor == 'dependabot[bot]' }}
166-
steps:
167-
- name: Dependabot metadata
168-
id: metadata
169-
uses: dependabot/fetch-metadata@v1.1.1
170-
with:
171-
github-token: "${{ secrets.GITHUB_TOKEN }}"
172-
- name: Enable auto-merge for Dependabot PRs
173-
run: gh pr merge --auto --merge "$PR_URL"
174-
env:
175-
PR_URL: ${{github.event.pull_request.html_url}}
176-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)