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

feat(ci): use GitHub artifacts POC #469

Merged
merged 15 commits into from
May 4, 2022
Merged

feat(ci): use GitHub artifacts POC #469

merged 15 commits into from
May 4, 2022

Conversation

shortcuts
Copy link
Member

@shortcuts shortcuts commented May 2, 2022

🧭 What and Why

🎟 JIRA Ticket: https://algolia.atlassian.net/browse/APIC-455

Changes included:

This PR adds GitHub artifact to the CI, used to pass data from a job to an other.

All the previous logic related to the cache has been removed, we now use cache as an easy way to skip jobs.

The client matrix has been grouped so we don't have to handle languages from here

🧪 Test

CI :D

@shortcuts shortcuts self-assigned this May 2, 2022
@netlify
Copy link

netlify bot commented May 2, 2022

Deploy Preview for api-clients-automation canceled.

Name Link
🔨 Latest commit c453f36
🔍 Latest deploy log https://app.netlify.com/sites/api-clients-automation/deploys/627279fda1443e0009031b9c

@algolia-bot
Copy link
Collaborator

algolia-bot commented May 2, 2022

✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the main branch.

@shortcuts shortcuts force-pushed the chore/github-artifacts branch from 13bd250 to 86f4066 Compare May 2, 2022 15:49
Comment on lines 5 to 6
summary: Search in an index THIS_IS_A_TEST.
description: Perform a search operation targeting one specific index THIS_IS_A_TEST.
Copy link
Member Author

@shortcuts shortcuts May 2, 2022

Choose a reason for hiding this comment

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

This is only here to have a generated change to test

@@ -0,0 +1,326 @@
name: Restore all artifacts
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the most annoying part of artifacts, it does not restore at the path that was stored, so we have to implicitly set it, there might be a way to either:

  • Generate this file
  • Make the thing less redundant

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok it's a bit better now but still redundant

@@ -402,10 +381,20 @@ jobs:
- name: Check JavaScript client size
run: exit $(yarn workspace algoliasearch-client-javascript test:size | echo $?)

# ----> This can be added once the PHP build for the CTS is fixed
Copy link
Member Author

Choose a reason for hiding this comment

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

@shortcuts shortcuts changed the title feat(ci): use GitHub artifacts feat(ci): use GitHub artifacts POC May 3, 2022
steps.diff.outputs.JS_COMMON_CHANGED > 0 }}
algoliasearch_changed=${{ steps.diff.outputs.JS_ALGOLIASEARCH_CHANGED > 0 }}
common_changed=${{ steps.diff.outputs.JS_COMMON_CHANGED > 0 }}
steps.diff.outputs.JS_UTILS_CHANGED > 0 ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

We loose all the granularity here, we can change one template without affecting the other languages. the LANGUAGE_TEMPLATE_CHANGED should be computed inside the script for each language, or passed here but it will be verbose.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree!

I have an other change locally that moves the base_changed logic in TS but I thought it was too much for this PR

.github/workflows/check.yml Outdated Show resolved Hide resolved
Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

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

Insane work ! The might be the solution to all our issues !

name: client-javascript-utils-${{ matrix.client }}
path: clients/algoliasearch-client-javascript/packages/${{ matrix.client }}

client_gen:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I really think this should be split by language instead of trying to factorize, for example the Java client need to be built at the end or it won't work in some cases, and doing that logic here is very complicated.
I'm not sure this makes it easier to read either, it's very nice to remove duplication but hard with yaml

Copy link
Member Author

@shortcuts shortcuts May 3, 2022

Choose a reason for hiding this comment

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

Yeah the main goal was just to remove the language logic but I'm not a fan of it looking again

I still wonder if making the CLI allow variadic params could be easier to handle those cases, but idk how it would impact the job time

Copy link
Collaborator

Choose a reason for hiding this comment

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

I will remove logic this in my next PR to allow for client_java_build, like here, are you sure you want to keep that code ?

scripts/ci/createMatrix.ts Outdated Show resolved Hide resolved
.github/actions/setup/action.yml Outdated Show resolved Hide resolved
@shortcuts shortcuts requested a review from millotp May 3, 2022 16:09
@shortcuts shortcuts marked this pull request as ready for review May 3, 2022 16:13
@shortcuts shortcuts force-pushed the chore/github-artifacts branch from 225a62d to 8c8ac94 Compare May 4, 2022 08:09

echo "Running spec matrix: $run"
echo "Spec matrix: $(echo $matrix | jq .)"
run: yarn workspace scripts createMatrix ${{ steps.diff.outputs.ORIGIN_BRANCH }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could be in the same step as the one above

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed because it does not require output variables, but (1st I did not know it would work :D) and also it's more explicit what it does like this

Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

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

Very cool !

.github/workflows/check.yml Outdated Show resolved Hide resolved
.github/workflows/check.yml Outdated Show resolved Hide resolved
/**
* List of dependencies based on the language, inherited from `./setRunVariables.ts` in a more dynamic form.
*/
const MATRIX_DEPENDENCIES = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this could just hold the name of the property, like 'GITHUB_ACTIONS_CHANGED' and fetch it from DEPENDENCIES in the isBaseChanged function, as you want.

scripts/ci/githubActions/createMatrix.ts Outdated Show resolved Hide resolved
scripts/ci/githubActions/utils.ts Outdated Show resolved Hide resolved
scripts/ci/githubActions/utils.ts Outdated Show resolved Hide resolved
Comment on lines +59 to +61
const clientChanges = await getNbGitDiff({
branch: baseBranch,
path: output,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The output is not committed so why check for it here ? the diff should be based on the same dependencies as the cache I think

Copy link
Member Author

Choose a reason for hiding this comment

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

This was already here before but IIRC it's mostly for changes related to non-generated changes, that are pushed (package.json, utils packages etc.)

@shortcuts shortcuts requested a review from millotp May 4, 2022 10:19
Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

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

One last comment !


return `${baseName}-${crypto
.createHash('sha256')
.update(`${await commonCacheKey}-${hash}`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will still get computed for each cache key, can you put it in a variable without the await ?

Copy link
Member Author

@shortcuts shortcuts May 4, 2022

Choose a reason for hiding this comment

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

wdym? commonCacheKey is only called once a createMatrix call with this

Copy link
Collaborator

Choose a reason for hiding this comment

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

your right this is a very weird way of doing it ahah

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to do top level await but can't manage to make it work, if you have an alternative lmk!

Copy link
Collaborator

@millotp millotp May 4, 2022

Choose a reason for hiding this comment

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

I was thinking of calling it inside createMatrix function and setRunVariable function, just as a setup

Copy link
Collaborator

Choose a reason for hiding this comment

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

and it will set a global variable

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes out of the utils, I don't really mind I can change if you want

Copy link
Collaborator

Choose a reason for hiding this comment

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

it works like that don't mind


return `${baseName}-${crypto
.createHash('sha256')
.update(`${await commonCacheKey}-${hash}`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

your right this is a very weird way of doing it ahah

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