Skip to content

Commit

Permalink
chore(curriculum): remove BUILD_WITH_SUBMODULE env variable (freeCode…
Browse files Browse the repository at this point in the history
  • Loading branch information
moT01 authored Jul 26, 2024
1 parent 82ec052 commit 99023bf
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 39 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/curriculum-i18n-submodule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ jobs:
- name: Set Environment variables
run: |
cp sample.env .env
echo 'BUILD_WITH_SUBMODULE=true' >> .env
# TODO: Remove this ^ after migration is complete
- name: Install node_modules
run: pnpm install
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/e2e-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ jobs:
- name: Set freeCodeCamp Environment Variables
run: |
cp sample.env .env
echo 'BUILD_WITH_SUBMODULE=true' >> .env
# TODO: Remove this ^ after migration is complete
- name: Install and Build
run: |
Expand Down Expand Up @@ -132,8 +130,6 @@ jobs:
- name: Set freeCodeCamp Environment Variables
run: |
cp sample.env .env
echo 'BUILD_WITH_SUBMODULE=true' >> .env
# TODO: Remove this ^ after migration is complete
- name: Install and Build
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/e2e-third-party.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: 'recursive'

- name: Checkout client-config
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/e2e-with-new-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: 'recursive'

- name: Checkout client-config
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down Expand Up @@ -79,6 +81,8 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: 'recursive'

- name: Create Image
run: |
Expand All @@ -96,6 +100,8 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: 'recursive'

- name: Create Image
run: |
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/i18n-validate-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ jobs:
- name: Set freeCodeCamp Environment Variables
run: |
cp sample.env .env
echo 'BUILD_WITH_SUBMODULE=true' >> .env
# TODO: Remove this ^ after migration is complete
- name: Install Dependencies
run: pnpm install
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/i18n-validate-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
- name: Set freeCodeCamp Environment Variables
run: |
cp sample.env .env
echo 'BUILD_WITH_SUBMODULE=true' >> .env
# TODO: Remove this ^ after migration is complete
- name: Install Dependencies
run: pnpm install
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/node.js-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
run: |
cp sample.env .env
cat .env
# TODO: Remove this ^ after migration is complete
- name: Install node_modules
run: pnpm install
Expand Down Expand Up @@ -104,8 +103,6 @@ jobs:
- name: Set freeCodeCamp Environment Variables
run: |
cp sample.env .env
echo 'BUILD_WITH_SUBMODULE=true' >> .env
# TODO: Remove this ^ after migration is complete
- name: Install and Build
run: |
Expand Down Expand Up @@ -142,9 +139,7 @@ jobs:
- name: Set Environment variables
run: |
cp sample.env .env
echo 'BUILD_WITH_SUBMODULE=true' >> .env
cat .env
# TODO: Remove this ^ after migration is complete
- name: Start MongoDB
uses: supercharge/mongodb-github-action@b0a1493307c4e9b82ed61f3858d606c5ff190c64 # v1.10.0
Expand Down Expand Up @@ -196,9 +191,7 @@ jobs:
cp sample.env .env
echo 'SHOW_UPCOMING_CHANGES=true' >> .env
echo 'SHOW_NEW_CURRICULUM=true' >> .env
echo 'BUILD_WITH_SUBMODULE=true' >> .env
cat .env
# TODO: Remove this ^ after migration is complete
- name: Start MongoDB
uses: supercharge/mongodb-github-action@b0a1493307c4e9b82ed61f3858d606c5ff190c64 # v1.10.0
Expand Down Expand Up @@ -249,9 +242,7 @@ jobs:
- name: Set Environment variables
run: |
cp sample.env .env
echo 'BUILD_WITH_SUBMODULE=true' >> .env
cat .env
# TODO: Remove this ^ after migration is complete
- name: Start MongoDB
uses: supercharge/mongodb-github-action@b0a1493307c4e9b82ed61f3858d606c5ff190c64 # v1.10.0
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/temporary-container-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: 'recursive'

- name: Create Image
run: |
Expand Down Expand Up @@ -61,6 +63,8 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: 'recursive'

- name: Create Image
run: |
Expand All @@ -78,6 +82,8 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: 'recursive'

- name: Create Image
run: |
Expand Down
8 changes: 6 additions & 2 deletions client/utils/build-challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
generateChallengeCreator,
ENGLISH_CHALLENGES_DIR,
META_DIR,
CHALLENGES_DIR,
I18N_CHALLENGES_DIR,
getChallengesDirForLang
} = require('../../curriculum/get-challenges');

Expand All @@ -30,7 +30,11 @@ exports.replaceChallengeNode = () => {
'english',
filePath
);
const i18nPath = path.resolve(CHALLENGES_DIR, curriculumLocale, filePath);
const i18nPath = path.resolve(
I18N_CHALLENGES_DIR,
curriculumLocale,
filePath
);
// TODO: reimplement hot-reloading of certifications
const createChallenge = generateChallengeCreator(
curriculumLocale,
Expand Down
28 changes: 13 additions & 15 deletions curriculum/get-challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,29 @@ const ENGLISH_CHALLENGES_DIR = path.resolve(__dirname, 'challenges');
const ENGLISH_DICTIONARIES_DIR = path.resolve(__dirname, 'dictionaries');
const META_DIR = path.resolve(ENGLISH_CHALLENGES_DIR, '_meta');

const CURRICULUM_DIR = path.resolve(
// This is to allow English to build without having to download the i18n files.
// It fails when trying to resolve the i18n-curriculum path if they don't exist.
const I18N_CURRICULUM_DIR = path.resolve(
__dirname,
process.env.BUILD_WITH_SUBMODULE === 'true'
? 'i18n-curriculum/curriculum'
: '.'
process.env.CURRICULUM_LOCALE === 'english'
? '.'
: 'i18n-curriculum/curriculum'
);

const CHALLENGES_DIR = path.resolve(CURRICULUM_DIR, 'challenges');
const DICTIONARIES_DIR = path.resolve(CURRICULUM_DIR, 'dictionaries');
const I18N_CHALLENGES_DIR = path.resolve(I18N_CURRICULUM_DIR, 'challenges');
const I18N_DICTIONARIES_DIR = path.resolve(I18N_CURRICULUM_DIR, 'dictionaries');

exports.ENGLISH_CHALLENGES_DIR = ENGLISH_CHALLENGES_DIR;
exports.META_DIR = META_DIR;
exports.CHALLENGES_DIR = CHALLENGES_DIR;
exports.I18N_CHALLENGES_DIR = I18N_CHALLENGES_DIR;

const COMMENT_TRANSLATIONS = createCommentMap(
DICTIONARIES_DIR,
I18N_DICTIONARIES_DIR,
ENGLISH_DICTIONARIES_DIR
);

function createCommentMap(dictionariesDir, englishDictionariesDir) {
// get all the languages for which there are dictionaries. Note: the english
// entries are created separately, so we remove it from languages.
const languages = fs
.readdirSync(dictionariesDir)
.filter(lang => lang !== 'english'); // TODO: Remove the filter after migrating to i18n-curriculum
const languages = fs.readdirSync(dictionariesDir);

// get all their dictionaries
const dictionaries = languages.reduce(
Expand Down Expand Up @@ -130,7 +128,7 @@ function getChallengesDirForLang(lang) {
if (lang === 'english') {
return path.resolve(ENGLISH_CHALLENGES_DIR, `${lang}`);
} else {
return path.resolve(CHALLENGES_DIR, `${lang}`);
return path.resolve(I18N_CHALLENGES_DIR, `${lang}`);
}
}

Expand Down Expand Up @@ -258,7 +256,7 @@ async function buildChallenges({ path: filePath }, curriculum, lang) {
'english',
filePath
);
const i18nPath = path.resolve(__dirname, CHALLENGES_DIR, lang, filePath);
const i18nPath = path.resolve(__dirname, I18N_CHALLENGES_DIR, lang, filePath);
const createChallenge = generateChallengeCreator(lang, englishPath, i18nPath);

await assertHasEnglishSource(filePath, lang, englishPath);
Expand Down
3 changes: 0 additions & 3 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ FREECODECAMP_NODE_ENV=development
CLIENT_LOCALE=english
CURRICULUM_LOCALE=english

# Build using submodule - remove this once the workflow has been entirely moved to use the submodule
BUILD_WITH_SUBMODULE=false

# Show or hide WIP in progress challenges
SHOW_UPCOMING_CHANGES=false
SHOW_NEW_CURRICULUM=false
Expand Down

0 comments on commit 99023bf

Please sign in to comment.