Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable everything #1

Closed
wants to merge 6 commits into from
Closed

Enable everything #1

wants to merge 6 commits into from

Conversation

SaschaMann
Copy link
Contributor

No description provided.

@@ -0,0 +1,107 @@
- name: "bug :bug:"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a file I used for testing.

Comment on lines 33 to 36
//return trackRepos.flatMap(({ full_name }) => full_name === 'exercism/research_experiment_1' ? [] : [full_name])

// TODO: Before merge, remove this and uncomment the line above
return ['exercism/julia']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//return trackRepos.flatMap(({ full_name }) => full_name === 'exercism/research_experiment_1' ? [] : [full_name])
// TODO: Before merge, remove this and uncomment the line above
return ['exercism/julia']
return trackRepos.flatMap(({ full_name }) => full_name === 'exercism/research_experiment_1' ? [] : [full_name])

^ To 'arm' the repo/workflow before merging

@SaschaMann
Copy link
Contributor Author

How it works:

On each push to the main branch, all files in synced-files/ will be copied to all Exercism track repos.
A PR will be opened on each repo, which will (in the future) be automatically merged by a webhook integration.

After pushing, you have 5 minutes to abort the workflow, in case there are any errors in the files that should be synced.

@SaschaMann SaschaMann marked this pull request as ready for review March 5, 2021 12:51
})

// research_experiment_1 is not a real track, don't treat it as one
//return trackRepos.flatMap(({ full_name }) => full_name === 'exercism/research_experiment_1' ? [] : [full_name])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just removed the label from this track (cc @ErikSchierboom for your scripts too)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice

Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, but it is hard to review these CI actions :)

with:
github-token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
script: |
const botRepos = await github.paginate(github.repos.listForAuthenticatedUser, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird that you can filter on forks. 🤷

Comment on lines 47 to 50
// Replacing the bot username with exercism is slightly hacky, but necessary
// for the comparison below. Unfortunately, GitHub's API response does not seem
// to contain any reference to the upstream repo of the fork.
const botForks = botRepos.flatMap(({ full_name, fork }) => fork ? [full_name.replace(process.env.BOT_USERNAME, 'exercism')] : [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The graphql API does allow for referencing the upstream repo, which they refer to as the "parent". E.g., the following graphql will output all the forked repos with their forked name and upstream name:

{
  user(login: "ErikSchierboom") {
    repositories(first: 100, isFork: true) {
      nodes {
        nameWithOwner
        parent {
          nameWithOwner
        }
      }
    }
  }
}

Which outputs:

{
  "data": {
    "user": {
      "repositories": {
        "nodes": [
          {
            "nameWithOwner": "ErikSchierboom/fsharp",
            "parent": {
              "nameWithOwner": "exercism/fsharp"
            }
          },
          {
            "nameWithOwner": "ErikSchierboom/problem-specifications",
            "parent": {
              "nameWithOwner": "exercism/problem-specifications"
            }
          },
          ...
        ]
      }
    }
  }
}

You can try this yourself at https://docs.github.com/en/graphql/overview/explorer

According to the docs, actions/github-script allows you to run graphql queries: https://github.com/actions/toolkit/tree/master/packages/github

The main disadvantage is that you'd have to do manual pagination, so it might be not that convenient after all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be useful, I'll take a look.

Copy link
Contributor Author

@SaschaMann SaschaMann Mar 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave this open as a future TODO for now, I'm not sure if the added complexity of manual pagination is worth it, and I don't know graphql at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Comment on lines +75 to +77
// Forking repos happens asynchronously on GitHub, therefore
// we need to sleep a bit to ensure it has been created
await new Promise(x => setTimeout(x, 60000))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use a different mechanism (e.g. polling) to be certain that the fork was actually created?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's worth it. Tracks aren't created that often, this will rarely ever run

@SaschaMann SaschaMann closed this May 28, 2021
@SaschaMann SaschaMann deleted the dev branch May 29, 2021 11:20
ErikSchierboom added a commit that referenced this pull request Mar 4, 2022
There are three GitHub Actions workflows that are present in many Exercism repositories, but whose contents are identical:

1. Track repos: the workflow to run `configlet lint`
2. Tooling repos: the workflow to deploy the tool as a Docker image
3. All repos: the workflow to sync labels

Having duplicated workflows has two main disadvantages:

1. Updating the workflow means submitting a PR to each repository
2. Each repository gets their own dependabot update PRs

Both of these disadvantages result in (many) notifications for track maintainers, which can be quite annoying.

Solving these problems is done in three steps:

1. We've extracted the shared workflow functionality into reusable workflows that are stored in the exercism/github-actions repository: https://github.com/exercism/github-actions/tree/main/.github/workflows.
2. Modify the workflows currently having duplicated functionality to instead use the reusable workflows.
3. Automatically synchronize the modified workflows from the https://github.com/exercism/org-wide-files repository.

Once all these steps have completed, the three above-mentioned cross-repository workflows:

- will be identical across the different repositories
- will rely on the reusable workflows for their functionality
- won't receive dependabot updates as they don't have versioned github action imports (the reusable workflows use `@main`)
- can easily be updated in a single location without needing bulk PRs

While working on this, we've also made two tiny non-related changes (yeah, this is bad practice, I know :)):

1. We've prepared the `configlet` workflow to allow tracks to opt into also running `configlet fmt` (check the formatting of files in a track's repository). We still need to do a little work in the `org-wide-files` repo to allow track repositories to enable this, but in the end this should be as simple as setting a boolean flag to `true` in a (new) configuration file.
2. The workflows now all have explicit permissions, which improves their security.

Note #1: sometimes we merge minor changes like typo fixes in `org-wide-files` without triggering a bulk PR. Therefore, there might be more files that are synced than just the reusable workflows.

Note #2: there will be a follow-up PR cleaning up duplicate configlet workflows in case the track's configlet workflow has a different name.
ErikSchierboom added a commit that referenced this pull request Mar 4, 2022
There are three GitHub Actions workflows that are present in many Exercism repositories, but whose contents are identical:

1. Track repos: the workflow to run `configlet lint`
2. Tooling repos: the workflow to deploy the tool as a Docker image
3. All repos: the workflow to sync labels

Having duplicated workflows has two main disadvantages:

1. Updating the workflow means submitting a PR to each repository
2. Each repository gets their own dependabot update PRs

Both of these disadvantages result in (many) notifications for track maintainers, which can be quite annoying.

Solving these problems is done in three steps:

1. We've extracted the shared workflow functionality into reusable workflows that are stored in the exercism/github-actions repository: https://github.com/exercism/github-actions/tree/main/.github/workflows.
2. Modify the workflows currently having duplicated functionality to instead use the reusable workflows.
3. Automatically synchronize the modified workflows from the https://github.com/exercism/org-wide-files repository.

Once all these steps have completed, the three above-mentioned cross-repository workflows:

- will be identical across the different repositories
- will rely on the reusable workflows for their functionality
- won't receive dependabot updates as they don't have versioned github action imports (the reusable workflows use `@main`)
- can easily be updated in a single location without needing bulk PRs

While working on this, we've also made two tiny non-related changes (yeah, this is bad practice, I know :)):

1. We've prepared the `configlet` workflow to allow tracks to opt into also running `configlet fmt` (check the formatting of files in a track's repository). We still need to do a little work in the `org-wide-files` repo to allow track repositories to enable this, but in the end this should be as simple as setting a boolean flag to `true` in a (new) configuration file.
2. The workflows now all have explicit permissions, which improves their security.

Note #1: sometimes we merge minor changes like typo fixes in `org-wide-files` without triggering a bulk PR. Therefore, there might be more files that are synced than just the reusable workflows.

Note #2: there will be a follow-up PR cleaning up duplicate configlet workflows in case the track's configlet workflow has a different name.
ErikSchierboom added a commit that referenced this pull request Mar 4, 2022
There are three GitHub Actions workflows that are present in many Exercism repositories, but whose contents are identical:

1. Track repos: the workflow to run `configlet lint`
2. Tooling repos: the workflow to deploy the tool as a Docker image
3. All repos: the workflow to sync labels

Having duplicated workflows has two main disadvantages:

1. Updating the workflow means submitting a PR to each repository
2. Each repository gets their own dependabot update PRs

Both of these disadvantages result in (many) notifications for track maintainers, which can be quite annoying.

Solving these problems is done in three steps:

1. We've extracted the shared workflow functionality into reusable workflows that are stored in the exercism/github-actions repository: https://github.com/exercism/github-actions/tree/main/.github/workflows.
2. Modify the workflows currently having duplicated functionality to instead use the reusable workflows.
3. Automatically synchronize the modified workflows from the https://github.com/exercism/org-wide-files repository.

Once all these steps have completed, the three above-mentioned cross-repository workflows:

- will be identical across the different repositories
- will rely on the reusable workflows for their functionality
- won't receive dependabot updates as they don't have versioned github action imports (the reusable workflows use `@main`)
- can easily be updated in a single location without needing bulk PRs

While working on this, we've also made two tiny non-related changes (yeah, this is bad practice, I know :)):

1. We've prepared the `configlet` workflow to allow tracks to opt into also running `configlet fmt` (check the formatting of files in a track's repository). We still need to do a little work in the `org-wide-files` repo to allow track repositories to enable this, but in the end this should be as simple as setting a boolean flag to `true` in a (new) configuration file.
2. The workflows now all have explicit permissions, which improves their security.

Note #1: sometimes we merge minor changes like typo fixes in `org-wide-files` without triggering a bulk PR. Therefore, there might be more files that are synced than just the reusable workflows.

Note #2: there will be a follow-up PR cleaning up duplicate configlet workflows in case the track's configlet workflow has a different name.
SaschaMann added a commit that referenced this pull request Mar 4, 2022
There are three GitHub Actions workflows that are present in many Exercism repositories, but whose contents are identical:

1. Track repos: the workflow to run `configlet lint`
2. Tooling repos: the workflow to deploy the tool as a Docker image
3. All repos: the workflow to sync labels

Having duplicated workflows has two main disadvantages:

1. Updating the workflow means submitting a PR to each repository
2. Each repository gets their own dependabot update PRs

Both of these disadvantages result in (many) notifications for track maintainers, which can be quite annoying.

Solving these problems is done in three steps:

1. We've extracted the shared workflow functionality into reusable workflows that are stored in the exercism/github-actions repository: https://github.com/exercism/github-actions/tree/main/.github/workflows.
2. Modify the workflows currently having duplicated functionality to instead use the reusable workflows.
3. Automatically synchronize the modified workflows from the https://github.com/exercism/org-wide-files repository.

Once all these steps have completed, the three above-mentioned cross-repository workflows:

- will be identical across the different repositories
- will rely on the reusable workflows for their functionality
- won't receive dependabot updates as they don't have versioned github action imports (the reusable workflows use `@main`)
- can easily be updated in a single location without needing bulk PRs

While working on this, we've also made two tiny non-related changes (yeah, this is bad practice, I know :)):

1. We've prepared the `configlet` workflow to allow tracks to opt into also running `configlet fmt` (check the formatting of files in a track's repository). We still need to do a little work in the `org-wide-files` repo to allow track repositories to enable this, but in the end this should be as simple as setting a boolean flag to `true` in a (new) configuration file.
2. The workflows now all have explicit permissions, which improves their security.

Note #1: sometimes we merge minor changes like typo fixes in `org-wide-files` without triggering a bulk PR. Therefore, there might be more files that are synced than just the reusable workflows.

Note #2: there will be a follow-up PR cleaning up duplicate configlet workflows in case the track's configlet workflow has a different name.
ErikSchierboom added a commit that referenced this pull request Mar 10, 2022
Use reusable workflows for cross-repository workflows

There are three GitHub Actions workflows that are present in many Exercism repositories, but whose contents are identical:

1. Track repos: the workflow to run `configlet lint`
2. Tooling repos: the workflow to deploy the tool as a Docker image
3. All repos: the workflow to sync labels

Having duplicated workflows has two main disadvantages:

1. Updating the workflow means submitting a PR to each repository
2. Each repository gets their own dependabot update PRs

Both of these disadvantages result in (many) notifications for track maintainers, which can be quite annoying.

Solving these problems is done in three steps:

1. We've extracted the shared workflow functionality into reusable workflows that are stored in the exercism/github-actions repository: https://github.com/exercism/github-actions/tree/main/.github/workflows.
2. Modify the workflows currently having duplicated functionality to instead use the reusable workflows.
3. Automatically synchronize the modified workflows from the https://github.com/exercism/org-wide-files repository.

Once all these steps have completed, the three above-mentioned cross-repository workflows:

- will be identical across the different repositories
- will rely on the reusable workflows for their functionality
- won't receive dependabot updates as they don't have versioned github action imports (the reusable workflows use `@main`)
- can easily be updated in a single location without needing bulk PRs

While working on this, we've also made two tiny non-related changes (yeah, this is bad practice, I know :)):

1. We've prepared the `configlet` workflow to allow tracks to opt into also running `configlet fmt` (check the formatting of files in a track's repository). We still need to do a little work in the `org-wide-files` repo to allow track repositories to enable this, but in the end this should be as simple as setting a boolean flag to `true` in a (new) configuration file.
2. The workflows now all have explicit permissions, which improves their security.

Note #1: sometimes we merge minor changes like typo fixes in `org-wide-files` without triggering a bulk PR. Therefore, there might be more files that are synced than just the reusable workflows.

Note #2: there will be a follow-up PR cleaning up duplicate configlet workflows in case the track's configlet workflow has a different name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants